Class: WhalesDispatch::Params
- Inherits:
-
Object
- Object
- WhalesDispatch::Params
show all
- Defined in:
- lib/whales_dispatch/params.rb
Defined Under Namespace
Classes: AttributeNotFoundError
Instance Method Summary
collapse
Constructor Details
#initialize(req, route_params = {}) ⇒ Params
Returns a new instance of Params.
6
7
8
9
10
|
# File 'lib/whales_dispatch/params.rb', line 6
def initialize(req, route_params = {})
parsed_query_string = parse_www_encoded_form(req.query_string)
parsed_req_body = parse_www_encoded_form(req.body)
@params = parsed_query_string.merge(parsed_req_body).merge(route_params)
end
|
Instance Method Details
#[](key) ⇒ Object
12
13
14
|
# File 'lib/whales_dispatch/params.rb', line 12
def [](key)
@params[key.to_s] || @params[key.to_sym]
end
|
#permit(*attrs) ⇒ Object
25
26
27
28
29
|
# File 'lib/whales_dispatch/params.rb', line 25
def permit(*attrs)
@params.select do |k, _|
attrs.include?(k.to_s) || attrs.include?(k.to_sym)
end
end
|
#require(key) ⇒ Object
20
21
22
23
|
# File 'lib/whales_dispatch/params.rb', line 20
def require(key)
@params = self[key]
self
end
|
#to_s ⇒ Object
16
17
18
|
# File 'lib/whales_dispatch/params.rb', line 16
def to_s
@params.to_s
end
|