ActiveInteraction and a big amount of other frameworks are using ActiveModel::Errors to implement errors.
When combined with other gems or frameworks that are using ActiveModel it is difficult to find out what class have called ActiveModel::Errors.new(self)
. For example the following case:
module MyAwesomeFramework class Errors < ActiveModel::Errors def merge!(other_instance_of_active_model_errors) if other_instance_of_active_model_errors.called_by? User # User is an ActiveRecord::Base # Use ActiveModel’s error translations else # Do magic to decide what translations to use end end end end
``
That is why I propose to expose something like
class ActiveModel::Errors
#…
def called_by?(klass) caller.class == klass end
def caller @base end
#…
end
``
Not sure about the name of method however.
Thanks in advance,
Ivan