Skip to content

Instantly share code, notes, and snippets.

@fgrehm fgrehm/gist:186797 forked from wiecklabs/gist:186777
Created Sep 14, 2009

What would you like to do?
class Address # Our custom, embedded-value type
accessor :address => String
accessor :address_2 => String
accessor :city => String
accessor :state => String
accessor :zip_code => String
orm.map_type do |signature, types|
signature.from [self]
signature.typecast_left method(:__load__) [types.string, types.string, types.string, types.string, types.string]
signature.typecast_right method(:__dump__)
class Zoo
accessor :id => Integer
accessor :name => String
accessor :address => Address, "zoos") do |zoos, type|
zoos.field :id, type.serial
zoos.field :name, type.string(200)
zoos.field :address, type.string(200, "address_address_1"),
type.string(100, "address_address_2"),
type.string(100, "address_city"),
type.string(50, "address_state"),
type.string(50, "address_zip_code")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.