Class: Hanami::Action::Params::Errors
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Hanami::Action::Params::Errors
- Defined in:
- lib/hanami/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.
53 54 55 |
# File 'lib/hanami/action/params.rb', line 53 def initialize(errors = {}) super(errors.dup) 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.
116 117 118 119 120 121 |
# File 'lib/hanami/action/params.rb', line 116 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 |