Class: GoodData::Bricks::UndotParamsMiddleware
- Inherits:
-
Middleware
- Object
- Middleware
- GoodData::Bricks::UndotParamsMiddleware
- Defined in:
- lib/gooddata/bricks/middleware/undot_params_middleware.rb
Overview
Converts params from double underscore notation to nested hash under 'config' Parameters starting GDC_ are considered system params and aren't converted.
This is useful because the executor platform can currently do just key-value parameters. Also it makes it easier for a user, as there aren't as much curly braces.
Examples
If you pass params in form: "value"
you'll get: {"namespace": {"param": value}}
Instance Attribute Summary
Attributes inherited from Middleware
Instance Method Summary collapse
Methods inherited from Middleware
Methods included from Utils
Constructor Details
This class inherits a constructor from GoodData::Bricks::Middleware
Instance Method Details
#call(params) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/gooddata/bricks/middleware/undot_params_middleware.rb', line 26 def call(params) params = params.to_hash unless params['config'] # split the params to those starting with GDC and those that don't, put other params under config gdc_params, other_params = params.partition { |k, _| k =~ /GDC_.*/ }.map { |h| Hash[h] } params = gdc_params.merge('config' => other_params.undot) end @app.call(params) end |