first commit
[merb_mart.git] / app / models / address.rb
blob9ea5f2a507ee7408c7b2bdf78909cf4cb914559b
2 # A generic representation of an Address.
4 class Address
5   include DataMapper::Resource
7   property :id,           Integer,  :serial => true
8   property :first_name,   String,   :length => 50, :nullable => false
9   property :last_name,    String,   :length => 50, :nullable => false
10   property :company,      String,   :length => 100
11   property :telephone,    String,   :length => 20
12   property :address1,     String,   :length => 200, :nullable => false
13   property :address2,     String,   :length => 200
14   property :city,         String,   :length => 50
15   property :postal_code,  String,   :length => 10,  :nullable => false
16   property :state_id,     Integer   # foreign-key
17   property :country_code, String    # foreign-key
19   belongs_to :state
20   belongs_to :country, :through => :state
22   alias :zipcode  :postal_code
23   alias :zipcode= :postal_code=
24   alias :province  :state
25   alias :province= :state=
27   def name
28     "#{self.first_name} #{self.last_name}"
29   end
31 end