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.



15
16
17
18
19
20
21
22
# File 'lib/transflow/step_dsl.rb', line 15

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

Instance Attribute Details

#containerObject (readonly)

Returns the value of attribute container.



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

def container
  @container
end

#handlerObject (readonly)

Returns the value of attribute handler.



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

def handler
  @handler
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#publishObject (readonly)

Returns the value of attribute publish.



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

def publish
  @publish
end

#stepsObject (readonly)

Returns the value of attribute steps.



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

def steps
  @steps
end

Instance Method Details

#callObject



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/transflow/step_dsl.rb', line 28

def call
  operation = container[handler]

  step =
    if publish
      Publisher.new(name, operation)
    else
      operation
    end

  steps[name] = step
end

#step(*args, &block) ⇒ Object



24
25
26
# File 'lib/transflow/step_dsl.rb', line 24

def step(*args, &block)
  self.class.new(*args, container, steps, &block).call
end