Class: Transflow::StepDSL

Inherits:
Object
  • Object
show all
Defined in:
lib/transflow/step_dsl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options, container, steps, &block) ⇒ StepDSL

Returns a new instance of StepDSL.



19
20
21
22
23
24
25
26
27
28
# File 'lib/transflow/step_dsl.rb', line 19

def initialize(name, options, container, steps, &block)
  @name = name
  @options = options
  @handler = options.fetch(:with, name)
  @publish = options.fetch(:publish, false)
  @monadic = options.fetch(:monadic, false)
  @container = container
  @steps = steps
  instance_exec(&block) if block
end

Instance Attribute Details

#containerObject (readonly)

Returns the value of attribute container.



11
12
13
# File 'lib/transflow/step_dsl.rb', line 11

def container
  @container
end

#handlerObject (readonly)

Returns the value of attribute handler.



9
10
11
# File 'lib/transflow/step_dsl.rb', line 9

def handler
  @handler
end

#monadicObject (readonly)

Returns the value of attribute monadic.



17
18
19
# File 'lib/transflow/step_dsl.rb', line 17

def monadic
  @monadic
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/transflow/step_dsl.rb', line 5

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/transflow/step_dsl.rb', line 7

def options
  @options
end

#publishObject (readonly)

Returns the value of attribute publish.



15
16
17
# File 'lib/transflow/step_dsl.rb', line 15

def publish
  @publish
end

#stepsObject (readonly)

Returns the value of attribute steps.



13
14
15
# File 'lib/transflow/step_dsl.rb', line 13

def steps
  @steps
end

Instance Method Details

#callObject



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/transflow/step_dsl.rb', line 34

def call
  operation = container[handler]

  step =
    if publish
      Publisher[name, operation, monadic: monadic]
    else
      operation
    end

  steps[name] = step
end

#step(name, new_options = {}, &block) ⇒ Object



30
31
32
# File 'lib/transflow/step_dsl.rb', line 30

def step(name, new_options = {}, &block)
  self.class.new(name, options.merge(new_options), container, steps, &block).call
end