Reputation: 1660
In Rails it's very easy to do things like User.first.monkeys.first.uncle, etc.
How could I get at this awesomeness without Rails and without a database? I noticed there's ActiveModel, but as far as I can tell it doesn't have any support for associations.
I'd like to be able to do things like this:
foo = Foo.new
foo.bars
# => []
foo.add_bar(:a => 'a')
foo.bars
# => [#<Bar @attr={:a=>'a'}>]
foo.bars.first.bazs
# => []
foo.bars.first.add_baz(:b=>'b')
foo.bars.first.bazs
# => [#<Baz @attr={:b=>'b'}]
foo.bars.first.foo
# => [#<Foo>]
Thanks in advance.
Upvotes: 2
Views: 309
Reputation: 211670
Why not just use an in-memory database with ActiveRecord and SQLite? You don't need to import all of Rails just to use the ORM. You could also use an alternative like Sequel or DataMapper depending on your preferences.
Upvotes: 3