Skip to content

Instantly share code, notes, and snippets.

@vsavkin
Created April 21, 2012 00:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vsavkin/2432865 to your computer and use it in GitHub Desktop.
Save vsavkin/2432865 to your computer and use it in GitHub Desktop.
Book, User, Address
class Book
include DataMapper::Resource
property :id, Serial
property :title, String
property :author, String
property :price, Decimal
end
class User
include DataMapper::Resource
property :id, Serial
property :name, String
property :address_country, String
property :address_city, String
validates_presence_of :name
def address= address
self.address_country = address.country
self.address_city = address.city
end
def address
Address.new(address_country, address_city)
end
end
class Address < Struct.new(:country, :city)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment