Module: WebPipe::Params

Included in:
Conn
Defined in:
lib/web_pipe/extensions/params/params.rb,
lib/web_pipe/extensions/params/params/transf.rb

Overview

See the docs for the extension linked from the README.

Defined Under Namespace

Modules: Transf

Constant Summary collapse

PARAM_TRANSFORMATION_KEY =

Key where configured transformations are set

:param_transformations

Instance Method Summary collapse

Instance Method Details

#params(transformation_specs = Types::Undefined) ⇒ Any

Parameters:

  • transformation_specs (Array<Symbol, Array>, Types::Undefined) (defaults to: Types::Undefined)

Returns:

  • (Any)


15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/web_pipe/extensions/params/params.rb', line 15

def params(transformation_specs = Types::Undefined)
  specs = if transformation_specs == Types::Undefined
            fetch_config(PARAM_TRANSFORMATION_KEY, [])
          else
            transformation_specs
          end
  transformations = specs.reduce(Transf[:id]) do |acc, t|
    acc.>>transformation(t)
  end

  Transf[transformations].call(request.params)
end