Skip to content

Commit

Permalink
[#753] put the inherited callback someplace it will actually get called
Browse files Browse the repository at this point in the history
  • Loading branch information
al2o3cr committed Sep 15, 2011
1 parent b5ee0fe commit f913d95
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions hobo/lib/hobo/model.rb
Expand Up @@ -33,17 +33,6 @@ class << base
alias_method_chain :attr_accessor, :creator_metadata

alias_method_chain :has_one, :new_method

# eval avoids the ruby 1.9.2 "super from singleton method ..." error
eval %(
def inherited(klass)
super
fields(false) do
Hobo.register_model(klass)
field(klass.inheritance_column, :string)
end
end
)
end

base.fields(false) # force hobo_fields to load
Expand Down Expand Up @@ -172,6 +161,18 @@ def field_added(name, type, args, options)
send(:login_attribute=, name.to_sym, validate) if options.delete(:login) && respond_to?(:login_attribute=)
end

# eval avoids the ruby 1.9.2 "super from singleton method ..." error
eval %(
def inherited(klass)
super
Hobo::Model.register_model(klass)
# TODO: figure out when this is needed, as Hobofields already does this
fields(false) do
field(klass.inheritance_column, :string)
end
end
)

private

def attrib_names
Expand Down

0 comments on commit f913d95

Please sign in to comment.