class Orchestra::Operation

Attributes

registry[RW]

Public Class Methods

new(*args, &block) click to toggle source
Calls superclass method
# File lib/orchestra/operation.rb, line 3
def self.new *args, &block
  return super unless block_given?
  unless args.empty?
    raise ArgumentError, "wrong number of arguments (#{args.size} for 0)"
  end
  builder = DSL::Operations::Builder.new
  DSL::Operations::Context.evaluate builder, &block
  builder.build_operation
end
new(args = {}) click to toggle source
# File lib/orchestra/operation.rb, line 20
def initialize args = {}
  @result, @command, @steps = Util.extract_key_args args,
    :result, :command => false, :steps => {}
  @default_run_list = RunList.build steps, result, []
end

Public Instance Methods

command?() click to toggle source
# File lib/orchestra/operation.rb, line 43
def command?
  @command ? true : false
end
execute(*args, &block) click to toggle source
# File lib/orchestra/operation.rb, line 30
def execute *args, &block
  execution = start_execution *args, &block
  output = execution.execute
  @command ? nil : output
end
process(output) click to toggle source
# File lib/orchestra/operation.rb, line 26
def process output
  output.select do |key, _| key = result end
end
start_execution(*args) { |execution| ... } click to toggle source
# File lib/orchestra/operation.rb, line 36
def start_execution *args
  conductor, input = extract_args args
  execution = Execution.build self, conductor, input
  yield execution if block_given?
  execution
end

Private Instance Methods

extract_args(args) click to toggle source
# File lib/orchestra/operation.rb, line 49
def extract_args args
  conductor = args.size > 1 ? args.shift : Conductor.new
  input = args.fetch 0 do {} end
  [conductor, input]
end