Class: ActiveModel::ErrorCollecting::MachineHashReporter
- Inherits:
-
HashReporter
show all
- Defined in:
- lib/active_model/error_collecting/machine_hash_reporter.rb
Instance Attribute Summary
Attributes inherited from Reporter
#collection
Instance Method Summary
collapse
Methods inherited from Reporter
#base, #initialize
Instance Method Details
14
15
16
17
18
19
|
# File 'lib/active_model/error_collecting/machine_hash_reporter.rb', line 14
def format_error_message(error_message)
result = {}
result[:type] = error_message.type || :invalid
result[:options] = error_message.options unless error_message.options.blank?
result
end
|
#to_hash ⇒ Object
4
5
6
7
8
9
10
11
12
|
# File 'lib/active_model/error_collecting/machine_hash_reporter.rb', line 4
def to_hash
collection.to_hash.inject({}) do |hash, kv|
attribute, error_message_set = kv
hash[attribute] = error_message_set.map do |error_message|
format_error_message(error_message)
end
hash
end
end
|