Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Book, User, Address

View book_user_address.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
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
Something went wrong with that request. Please try again.