Skip to content

Instantly share code, notes, and snippets.

@shostakovich
Created August 28, 2012 16:08
Show Gist options
  • Save shostakovich/3499567 to your computer and use it in GitHub Desktop.
Save shostakovich/3499567 to your computer and use it in GitHub Desktop.
describe "A way to extract address" do
it "creates a value object upon read" do
foo = Poi.new
foo.name = "test"
foo.company_name = "bar"
foo.title = "zzzzz"
foo.address.name.should == "test"
foo.address.company.should == "bar"
foo.address.title.should == "zzzzz"
end
it "can save the value object back" do
poi = Poi.new
poi.address = Poi::Address.new("test", "bar", "zzzzz")
poi.name.should == "test"
poi.company_name.should == "bar"
poi.title.should == "zzzzz"
end
end
require 'values'
class Poi
attr_accessor :name, :company_name, :title
Address = Value.new(:name, :company, :title)
def address
Address.new(name, company_name, title)
end
def address=(address)
self.name = address.name
self.company_name = address.company
self.title = address.title
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment