class Orchestra::DSL::Operations::Builder

Attributes

command[W]
result[W]

Public Class Methods

new() click to toggle source
# File lib/orchestra/dsl/operations.rb, line 7
def initialize
  @steps = {}
end

Public Instance Methods

add_step(name_or_object, args = {}) click to toggle source
# File lib/orchestra/dsl/operations.rb, line 21
def add_step name_or_object, args = {}, &block
  name, step = case name_or_object
  when Operation then build_embedded_operation_step name_or_object
  when ::String, ::Symbol then build_inline_step name_or_object, block
  else build_object_step name_or_object, args
  end
  step.provisions << name.to_sym if step.provisions.empty?
  set_step name.to_sym, step
end
build_embedded_operation_step(operation) click to toggle source
# File lib/orchestra/dsl/operations.rb, line 39
def build_embedded_operation_step operation
  name = object_name operation
  [name || operation.result, operation]
end
build_inline_step(name, block) click to toggle source
# File lib/orchestra/dsl/operations.rb, line 44
def build_inline_step name, block
  step = Step::InlineStep.build &block
  [name, step]
end
build_object_step(object, args) click to toggle source
# File lib/orchestra/dsl/operations.rb, line 49
def build_object_step object, args
  step = ObjectAdapter.build_step object, args
  name = object_name step.adapter
  [name, step]
end
build_operation() click to toggle source
# File lib/orchestra/dsl/operations.rb, line 11
def build_operation
  raise ArgumentError, "Must supply a result" if @result.nil?
  raise ArgumentError, "Must supply at least one step" if @steps.empty?
  Operation.new(
    :command => @command,
    :steps   => @steps,
    :result  => @result,
  )
end
set_step(name, step) click to toggle source
# File lib/orchestra/dsl/operations.rb, line 31
def set_step name, step
  if @steps.has_key? name
    raise ArgumentError, "There are duplicate steps named #{name.inspect}"
  end
  @steps[name] = step
  step.freeze
end

Private Instance Methods

object_name(object) click to toggle source
# File lib/orchestra/dsl/operations.rb, line 57
def object_name object
  object.name and Util.to_snake_case object.name
end