Class: ActiveModel::ErrorCollecting::HumanMessageReporter
- Inherits:
-
MessageReporter
- Object
- Reporter
- MessageReporter
- ActiveModel::ErrorCollecting::HumanMessageReporter
- Defined in:
- lib/active_model/error_collecting/human_message_reporter.rb
Instance Attribute Summary
Attributes inherited from Reporter
Instance Method Summary collapse
- #full_message(attribute, message) ⇒ Object
- #full_messages ⇒ Object
-
#generate_message(attribute, type = :invalid, options = {}) ⇒ Object
This method is not used internally.
Methods inherited from Reporter
Constructor Details
This class inherits a constructor from ActiveModel::ErrorCollecting::Reporter
Instance Method Details
#full_message(attribute, message) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/active_model/error_collecting/human_message_reporter.rb', line 12 def (attribute, ) return if attribute == :base attr_name = attribute.to_s.gsub('.', '_').humanize attr_name = base.class.human_attribute_name(attribute, :default => attr_name) I18n.t(:"errors.format", { :default => "%{attribute} %{message}", :attribute => attr_name, :message => }) end |
#full_messages ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/active_model/error_collecting/human_message_reporter.rb', line 4 def @collection.map do |attribute, | formatter = HumanMessageFormatter.new(base, ) = formatter. attribute, end end |
#generate_message(attribute, type = :invalid, options = {}) ⇒ Object
This method is not used internally. This is for API Compatibility with ActiveModel::Errors only
25 26 27 28 29 |
# File 'lib/active_model/error_collecting/human_message_reporter.rb', line 25 def (attribute, type = :invalid, = {}) = ErrorMessage.build(base, attribute, type, ) formatter = HumanMessageFormatter.new(base, ) formatter. end |