Created
August 28, 2012 16:08
-
-
Save shostakovich/3499567 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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