2 # A generic representation of an Address.
6 include DataMapper::Resource
8 property :id, Integer, :serial => true
9 property :first_name, String, :length => 50, :nullable => false
10 property :last_name, String, :length => 50, :nullable => false
11 property :company, String, :length => 100
12 property :telephone, String, :length => 20
13 property :address1, String, :length => 200, :nullable => false
14 property :address2, String, :length => 200
15 property :city, String, :length => 50
16 property :postal_code, String, :length => 10
17 property :state_id, Integer # foreign-key
18 property :country_code, String # foreign-key
23 validates_present :first_name
24 validates_present :last_name
25 validates_present :address1
26 validates_present :postal_code
28 validates_length :first_name, :maximum => 50
29 validates_length :last_name, :maximum => 50
30 validates_length :address1, :maximum => 255
32 alias :zipcode :postal_code
33 alias :zipcode= :postal_code=
34 alias :province :state
35 alias :province= :state=
38 "#{self.first_name} #{self.last_name}"