Class: Lotus::Action::Params
- Inherits:
-
Object
- Object
- Lotus::Action::Params
- Defined in:
- lib/lotus/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 Lotus::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.
Constant Summary collapse
- RACK_INPUT =
The key that returns raw input from the Rack env
'rack.input'.freeze
- ROUTER_PARAMS =
The key that returns router params from the Rack env This is a builtin integration for Lotus::Router
'router.params'.freeze
Instance Attribute Summary collapse
- #env ⇒ Object readonly private
Instance Method Summary collapse
-
#[](key) ⇒ Object?
Returns the object associated with the given key.
-
#initialize(env) ⇒ Params
constructor
Initialize the params and freeze them.
Constructor Details
#initialize(env) ⇒ Params
Initialize the params and freeze them.
40 41 42 43 44 |
# File 'lib/lotus/action/params.rb', line 40 def initialize(env) @env = env @params = Utils::Hash.new(_extract).symbolize! 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.
31 32 33 |
# File 'lib/lotus/action/params.rb', line 31 def env @env end |
Instance Method Details
#[](key) ⇒ Object?
Returns the object associated with the given key
53 54 55 |
# File 'lib/lotus/action/params.rb', line 53 def [](key) @params[key] end |