This is too much for my ruby skills level…
Since i can’t use multiple tables inheritance, i’ve been trying to
implement some shared behaviour and state in an AR ‘wrapper’ model
that delegates method calls to an associated business objects through
a polymorphic association
class CoreEntity < ActiveRecord::Base
belongs_to :business, :polymorphic => true
end
class FirstBusinessEntity < ActiveRecord::Base
has_one :core_entity, :as => :business
def some_business_method
return true
end
end
in the CoreEntity class, i can hard code :
delegate :some_business_method, :to => :business
and it works fine, but as soon as i’ll need to associate a different
business entity, i’m screwed.
Can I dynamically set the delegate parameters, depending on the
associated business object ?
Or am i looking at this the wrong way ?
cheers