Model refactorings and further expansion of specs
[merb_mart.git] / app / models / mart / accounts / abstract_account.rb
blob805fd99ae4aa570d48c8f407eda446f2a1947456
1 require 'dm-validations'
3 module Mart
4   module Accounts
5     class AbstractAccount
6   
7       include DataMapper::Resource
8       include DataMapper::Validate
9       require 'ezcrypto'
11       property :type,         Class   # single-table inheritance
12       property :order_id,     Fixnum  # foreign-key
13       property :customer_id,  Fixnum  # foreign-key
14     
15       has 1, :order
16       belongs_to :customer #, :accessor => :protected
18       def self.months
19         (1..12).to_a
20       end
21       
22       def self.years
23         year = Date.today.year
24         years = Array.new
25         (0..9).each do |n|
26           years << year + n
27         end
28         years
29       end
31     end
32   end
33 end