Class: Orchestra::Step::InlineStep::InlineContext

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(state, execute_block) ⇒ InlineContext

Returns a new instance of InlineContext.



112
113
114
115
# File 'lib/orchestra/step.rb', line 112

def initialize state, execute_block
  @__execute_block__ = execute_block
  @__state__ = state
end

Class Method Details

.define_dependency(dep) ⇒ Object



104
105
106
107
108
109
110
# File 'lib/orchestra/step.rb', line 104

def self.define_dependency dep
  define_method dep do
    ivar = "@#{dep}"
    return instance_variable_get ivar if instance_variable_defined? ivar
    instance_variable_set ivar, @__state__[dep]
  end
end

Instance Method Details

#execute(item = nil) ⇒ Object



117
118
119
120
121
122
123
# File 'lib/orchestra/step.rb', line 117

def execute item = nil
  if @__execute_block__.arity == 0
    instance_exec &@__execute_block__
  else
    instance_exec item, &@__execute_block__
  end
end