Hey y’all,
I’m using Rails module ActiveModel, which adds useful validation
behavior to descendants, including by reference to another class,
Errors, that in part composes it.
The initializer for the Errors class is…
def initialize(base)
@base = base
@messages = ActiveSupport::OrderedHash.new
end
…and ActiveModel implentations expose an instance of Errors with a
method #errors.
I would like to override particular methods on the Errors instance in my
ActiveModel implementation, sort of like as follows
def errors
some_state_i_want_to_add_to_the_pseudo_method_overwrite = …
super.tap {|e| e.extend
ExtraErrorsBehaviorWithStateFromCallingClassButHowToDoThis }
end
Moreover, I want this errors override to be useful if I inherit from the
ActiveModel implementation. So, in a descendant of the AR implementation
above, I might like to do this…
def errors
some_additional_state_i_want_to_add_to_the_pseudo_method_overwrite =
…
super.tap {|e| e.extend
EvenMoreExtraErrorsBehaviorWithStateFromCallingClassButHowToDoThis }
end
Any suggestions?
Thanks,
Grar