inheritance with Ohm

58 views
Skip to first unread message

Gunchars

unread,
Mar 14, 2012, 7:13:29 PM3/14/12
to Ohm Ruby
Hiya!

Dunno if anyone's reading this group, but just in case I have a quick
question. Is there a non hackish way to inheritance with Ohm::Model?
Something like this:

class A < Ohm::Model
attribute :a
end

class B < A
attribute :b
end

And then be able to do:

obj = B.new( { :a => "one", :b => "two" } )

I looked through the source of ohm and it seems that this isn't
possible without overriding self.attributes et al, but it's messing
with the internals of Ohm which feels like none of my business.
Thanks!

G.

Hung Tran

unread,
Sep 27, 2012, 7:08:34 PM9/27/12
to ohm-...@googlegroups.com
Hi - not sure if this is still relevant to you but the case you describe below seems to work for me in 1.2 in which you can initialize the inherited attribute during create.
Reply all
Reply to author
Forward
0 new messages