Class: Orchestra::Execution::Step

Inherits:
Object
  • Object
show all
Defined in:
lib/orchestra/execution.rb

Direct Known Subclasses

CollectionStep, EmbeddedOperation

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(step, name, operation_execution) ⇒ Step

Returns a new instance of Step.



93
94
95
96
97
98
# File 'lib/orchestra/execution.rb', line 93

def initialize step, name, operation_execution
  @name = name
  @operation_execution = operation_execution
  @step = step
  @context = build_context
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



91
92
93
# File 'lib/orchestra/execution.rb', line 91

def context
  @context
end

#nameObject (readonly)

Returns the value of attribute name.



91
92
93
# File 'lib/orchestra/execution.rb', line 91

def name
  @name
end

#nodeObject (readonly)

Returns the value of attribute node.



91
92
93
# File 'lib/orchestra/execution.rb', line 91

def node
  @node
end

#operation_executionObject (readonly)

Returns the value of attribute operation_execution.



91
92
93
# File 'lib/orchestra/execution.rb', line 91

def operation_execution
  @operation_execution
end

#stepObject (readonly)

Returns the value of attribute step.



91
92
93
# File 'lib/orchestra/execution.rb', line 91

def step
  @step
end

Class Method Details

.execute(step, *args) ⇒ Object



75
76
77
78
# File 'lib/orchestra/execution.rb', line 75

def self.execute step, *args
  instance = new step, *args
  instance.execute
end

.new(step, *args) ⇒ Object



80
81
82
83
84
85
86
87
88
89
# File 'lib/orchestra/execution.rb', line 80

def self.new step, *args
  if step.is_a? Orchestra::Operation
    klass = EmbeddedOperation
  else
    klass = step.collection ? CollectionStep : self
  end
  instance = klass.allocate
  instance.send :initialize, step, *args
  instance
end

Instance Method Details

#build_contextObject



119
120
121
# File 'lib/orchestra/execution.rb', line 119

def build_context
  step.build_context operation_execution.state
end

#executeObject



100
101
102
103
104
105
106
# File 'lib/orchestra/execution.rb', line 100

def execute
  @node = Recording::Node.new step, name, input
  operation_execution.publish :step_entered, node, node.input
  output = step.process invoke
  operation_execution.publish :step_exited, node, output
  output
end

#inputObject



108
109
110
111
112
113
# File 'lib/orchestra/execution.rb', line 108

def input
  registry = operation_execution.registry
  operation_execution.state.reject do |key, val|
    registry[key] == val or not step.dependencies.include? key
  end
end

#invokeObject



115
116
117
# File 'lib/orchestra/execution.rb', line 115

def invoke
  context.execute
end

#to_nodeObject



123
124
125
# File 'lib/orchestra/execution.rb', line 123

def to_node
  Node.new step, name
end