Class: ErrorBuilder::Formats::Hash

Inherits:
Base
  • Object
show all
Defined in:
lib/error_builder/formats/hash.rb

Instance Attribute Summary

Attributes inherited from Base

#errors, #flat

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from ErrorBuilder::Formats::Base

Instance Method Details

#to_hObject



6
7
8
9
10
11
12
# File 'lib/error_builder/formats/hash.rb', line 6

def to_h
  errors.each_with_object({}) do |error, hash|
    keys = flat ? [error.key] : error.keys

    add_nested_key(hash, keys, error.message)
  end
end