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
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.