Class: Macros::Contract::ExtractParams

Inherits:
Base
  • Object
show all
Defined in:
lib/macros/contract/extract_params.rb

Instance Method Summary collapse

Methods inherited from Base

register

Constructor Details

#initialize(from:) ⇒ Macros::Contract::ExtractParams

Returns step macro instance.

Examples:

scope not passed

Macros::Contract::ExtractParams(from: :scope)

Parameters:

  • from (Hash)

    key in params



11
12
13
# File 'lib/macros/contract/extract_params.rb', line 11

def initialize(from:)
  @from = from
end

Instance Method Details

#call(ctx) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/macros/contract/extract_params.rb', line 15

def call(ctx, **)
  return false unless ctx[:params]

  scope = ctx[@from]
  return false unless scope

  ctx['contract.default.params'] = ctx[:params][scope]
end