Class: ActiveModel::ErrorCollecting::MachineArrayReporter

Inherits:
ArrayReporter show all
Defined in:
lib/active_model/error_collecting/machine_array_reporter.rb

Instance Attribute Summary

Attributes inherited from Reporter

#collection

Instance Method Summary collapse

Methods inherited from Reporter

#base, #initialize

Constructor Details

This class inherits a constructor from ActiveModel::ErrorCollecting::Reporter

Instance Method Details

#format_error_message(error_message) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/active_model/error_collecting/machine_array_reporter.rb', line 10

def format_error_message(error_message)
  result = {}
  result[:attribute] = error_message.attribute.to_s
  result[:type] = error_message.type || :invalid
  result[:options] = error_message.options unless error_message.options.blank?
  result
end

#to_aObject



4
5
6
7
8
# File 'lib/active_model/error_collecting/machine_array_reporter.rb', line 4

def to_a
  collection.to_a.map do |error_message|
    format_error_message error_message
  end
end