Class: JobWorkflow::DryRunConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/job_workflow/dry_run_config.rb,
sig/generated/job_workflow/dry_run_config.rbs

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(evaluator: ->(_ctx) { false }) ⇒ DryRunConfig

: (?evaluator: ^(Context) -> bool) -> void

Parameters:

  • evaluator: (^(Context) -> bool) (defaults to: ->(_ctx) { false })


22
23
24
# File 'lib/job_workflow/dry_run_config.rb', line 22

def initialize(evaluator: ->(_ctx) { false })
  @evaluator = evaluator
end

Instance Attribute Details

#evaluator^(Context) -> bool (readonly)

Signature:

  • ^(Context) -> bool

Returns:



5
6
7
# File 'lib/job_workflow/dry_run_config.rb', line 5

def evaluator
  @evaluator
end

Class Method Details

.from_primitive_value(value) ⇒ DryRunConfig

: (bool | ^(Context) -> bool | nil) -> DryRunConfig

Parameters:

Returns:



9
10
11
12
13
14
15
16
17
18
# File 'lib/job_workflow/dry_run_config.rb', line 9

def from_primitive_value(value)
  case value
  when nil then new
  when true then new(evaluator: ->(_ctx) { true })
  when false then new(evaluator: ->(_ctx) { false })
  when Proc then new(evaluator: value)
  else
    raise ArgumentError, "dry_run must be true, false, or Proc"
  end
end

Instance Method Details

#evaluate(context) ⇒ Boolean

: (Context) -> bool

Parameters:

Returns:

  • (Boolean)


27
28
29
# File 'lib/job_workflow/dry_run_config.rb', line 27

def evaluate(context)
  @evaluator.call(context)
end