Class: BusinessFlow::Step::Inputs

Inherits:
Object
  • Object
show all
Defined in:
lib/business_flow/step.rb

Overview

Represents inputs needed to execute a step.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(inputs) ⇒ Inputs



9
10
11
# File 'lib/business_flow/step.rb', line 9

def initialize(inputs)
  @inputs = inputs
end

Instance Attribute Details

#inputsObject (readonly)

Returns the value of attribute inputs.



7
8
9
# File 'lib/business_flow/step.rb', line 7

def inputs
  @inputs
end

Class Method Details

.process_input(source, input_value) ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/business_flow/step.rb', line 23

def self.process_input(source, input_value)
  case input_value
  when Symbol
    source.send(input_value)
  when Proc
    source.instance_exec(&input_value)
  else
    input_value
  end
end

Instance Method Details

#parameters_from_source(source) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/business_flow/step.rb', line 13

def parameters_from_source(source)
  return source if inputs.blank?
  Hash[inputs.map do |input_name, input_value|
         [
           input_name,
           Inputs.process_input(source, input_value)
         ]
       end]
end