Class: Hanami::V1::Action::Params::Errors
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Hanami::V1::Action::Params::Errors
- Defined in:
- lib/hanami/v1/action/params.rb
Overview
Params errors
Instance Method Summary collapse
-
#add(*args) ⇒ Object
Add an error to the param validations.
-
#initialize(errors = {}) ⇒ Errors
constructor
private
A new instance of Errors.
Constructor Details
#initialize(errors = {}) ⇒ Errors
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Errors.
26 27 28 |
# File 'lib/hanami/v1/action/params.rb', line 26 def initialize(errors = {}) super(errors) end |
Instance Method Details
#add(*args) ⇒ Object
Add an error to the param validations
This has a semantic similar to ‘Hash#dig` where you use a set of keys to get a nested value, here you use a set of keys to set a nested value.
93 94 95 96 97 98 |
# File 'lib/hanami/v1/action/params.rb', line 93 def add(*args) *keys, key, error = args _nested_attribute(keys, key) << error rescue TypeError raise ArgumentError.new("Can't add #{args.map(&:inspect).join(', ')} to #{inspect}") end |