Class: Hanami::Action::Params
- Defined in:
- gems/gems/hanami-controller-2.1.0/lib/hanami/action/params.rb
Overview
A set of params requested by the client
It’s able to extract the relevant params from a Rack env of from an Hash.
There are three scenarios: * When used with Hanami::Router: it contains only the params from the request * When used standalone: it contains all the Rack env * Default: it returns the given hash as it is. It’s useful for testing purposes.
Defined Under Namespace
Classes: Errors
Instance Attribute Summary collapse
-
#errors ⇒ Hash
readonly
Returns structured error messages.
Class Method Summary collapse
-
.params(&blk) ⇒ Object
Define params validations.
Instance Method Summary collapse
-
#deconstruct_keys ⇒ ::Hash
Pattern-matching support.
-
#error_messages(error_set = errors) ⇒ Array
Returns flat collection of full error messages.
-
#raw ⇒ Hash
Returns raw params from Rack env.
-
#to_h ⇒ ::Hash
(also: #to_hash)
Serialize validated params to Hash.
-
#valid? ⇒ TrueClass, FalseClass
Returns true if no validation errors are found, false otherwise.
Instance Attribute Details
#errors ⇒ Hash (readonly)
Returns structured error messages
Source: | on GitHub
def errors @errors end |
Class Method Details
Instance Method Details
#deconstruct_keys ⇒ ::Hash
Pattern-matching support
Source: | on GitHub
def deconstruct_keys(*) to_hash end |
#error_messages(error_set = errors) ⇒ Array
Returns flat collection of full error messages
#to_h ⇒ ::Hash Also known as: to_hash
Serialize validated params to Hash
Source: | on GitHub
def to_h @params end |
#valid? ⇒ TrueClass, FalseClass
Returns true if no validation errors are found, false otherwise.
Source: | on GitHub
def valid? errors.empty? end |