Class: ActiveModel::ErrorCollecting::HumanHashReporter

Inherits:
HashReporter show all
Defined in:
lib/active_model/error_collecting/human_hash_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

#to_hashObject



4
5
6
7
8
9
10
11
12
# File 'lib/active_model/error_collecting/human_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|
      HumanMessageFormatter.new(base, error_message).format_message
    end
    hash
  end
end