Module: Core::Helpers::Parameters
- Included in:
- Controllers::Base
- Defined in:
- lib/core/helpers/parameters.rb
Overview
Helpers to correctly build the parameters hash, even from the JSON body.
Instance Method Summary collapse
-
#body_params ⇒ Hash
The parameters from the JSON body if it is sent.
-
#params ⇒ Hash
Returns the parameters depending on whether the request has a body or not.
Instance Method Details
#body_params ⇒ Hash
The parameters from the JSON body if it is sent.
17 18 19 20 21 22 |
# File 'lib/core/helpers/parameters.rb', line 17 def body_params request.body.rewind JSON.parse(request.body.read.to_s) rescue JSON::ParserError {} end |
#params ⇒ Hash
Returns the parameters depending on whether the request has a body or not. If it has a body, it parses it, otherwise it just returns the params.
11 12 13 |
# File 'lib/core/helpers/parameters.rb', line 11 def params super.merge(body_params) end |