Skip to content

Instantly share code, notes, and snippets.

@timfel
Created January 28, 2010 20:54
Show Gist options
  • Save timfel/289129 to your computer and use it in GitHub Desktop.
Save timfel/289129 to your computer and use it in GitHub Desktop.
>> class Test < Ohm::Model
?> attribute :name
?> set :tests, Test
?> end
=> [:tests]
>> t = Test.create(:name => "eins")
=> #<Test:3 name="eins" tests=#<Set: []>>
>> t2 = Test.create(:name => "zwei")
=> #<Test:4 name="zwei" tests=#<Set: []>>
>> t1.save
=> #<Test:3 name="eins" tests=#<Set: []>>
>> t2.save
=> #<Test:4 name="zwei" tests=#<Set: []>>
>> t.tests << t2
=> 1
>> t.tests
=> #<Set: ["#<Test:0x9c04f00>"]>
>> t.tests.first
=> nil
>> t.tests.send(:instantiate, "#<Test:0x9c04f00>")
=> [nil]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment