Class: Hanami::V1::Action::BaseParams
- Inherits:
-
Object
- Object
- Hanami::V1::Action::BaseParams
- Defined in:
- lib/hanami/v1/action/base_params.rb
Overview
Direct Known Subclasses
Constant Summary collapse
- RACK_INPUT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
The key that returns raw input from the Rack env
'rack.input'.freeze
- ROUTER_PARAMS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
The key that returns router params from the Rack env This is a builtin integration for Hanami::Router
'router.params'.freeze
- RACK_SESSION =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
The key that returns Rack session params from the Rack env Please note that this is used only when an action is unit tested.
'rack.session'.freeze
- REQUEST_METHOD =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
HTTP request method for Rack env
'REQUEST_METHOD'.freeze
- DEFAULT_REQUEST_METHOD =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Default HTTP request method for Rack env
'GET'.freeze
Instance Attribute Summary collapse
- #env ⇒ Object readonly private
- #raw ⇒ Object readonly private
Instance Method Summary collapse
-
#[](key) ⇒ Object?
Returns the object associated with the given key.
-
#each(&blk) ⇒ Object
Iterates through params.
-
#get(*keys) ⇒ Object, NilClass
(also: #dig)
Get an attribute value associated with the given key.
-
#initialize(env) ⇒ Params
constructor
private
Initialize the params and freeze them.
-
#to_h ⇒ ::Hash
(also: #to_hash)
Serialize params to Hash.
-
#valid? ⇒ TrueClass
Provide a common interface with Params.
Constructor Details
#initialize(env) ⇒ Params
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.
Initialize the params and freeze them.
65 66 67 68 69 70 |
# File 'lib/hanami/v1/action/base_params.rb', line 65 def initialize(env) @env = env @raw = _extract_params @params = Hanami::Utils::Hash.deep_symbolize(@raw) freeze end |
Instance Attribute Details
#env ⇒ Object (readonly)
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.
49 50 51 |
# File 'lib/hanami/v1/action/base_params.rb', line 49 def env @env end |
#raw ⇒ Object (readonly)
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.
55 56 57 |
# File 'lib/hanami/v1/action/base_params.rb', line 55 def raw @raw end |
Instance Method Details
#[](key) ⇒ Object?
Returns the object associated with the given key
79 80 81 |
# File 'lib/hanami/v1/action/base_params.rb', line 79 def [](key) @params[key] end |
#each(&blk) ⇒ Object
Iterates through params
150 151 152 |
# File 'lib/hanami/v1/action/base_params.rb', line 150 def each(&blk) to_h.each(&blk) end |
#get(*keys) ⇒ Object, NilClass Also known as: dig
Get an attribute value associated with the given key. Nested attributes are reached by listing all the keys to get to the value.
114 115 116 |
# File 'lib/hanami/v1/action/base_params.rb', line 114 def get(*keys) @params.dig(*keys) end |
#to_h ⇒ ::Hash Also known as: to_hash
Serialize params to Hash
140 141 142 |
# File 'lib/hanami/v1/action/base_params.rb', line 140 def to_h @params end |
#valid? ⇒ TrueClass
Provide a common interface with Params
131 132 133 |
# File 'lib/hanami/v1/action/base_params.rb', line 131 def valid? true end |