Class: Orchestra::DSL::Operations::Builder
- Inherits:
-
Object
- Object
- Orchestra::DSL::Operations::Builder
- Defined in:
- lib/orchestra/dsl/operations.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
writeonly
Sets the attribute command.
-
#result ⇒ Object
writeonly
Sets the attribute result.
Instance Method Summary collapse
- #add_step(name_or_object, args = {}, &block) ⇒ Object
- #build_embedded_operation_step(operation) ⇒ Object
- #build_inline_step(name, block) ⇒ Object
- #build_object_step(object, args) ⇒ Object
- #build_operation ⇒ Object
-
#initialize ⇒ Builder
constructor
A new instance of Builder.
- #set_step(name, step) ⇒ Object
Constructor Details
#initialize ⇒ Builder
Returns a new instance of Builder.
7 8 9 |
# File 'lib/orchestra/dsl/operations.rb', line 7 def initialize @steps = {} end |
Instance Attribute Details
#command=(value) ⇒ Object (writeonly)
Sets the attribute command
5 6 7 |
# File 'lib/orchestra/dsl/operations.rb', line 5 def command=(value) @command = value end |
#result=(value) ⇒ Object (writeonly)
Sets the attribute result
5 6 7 |
# File 'lib/orchestra/dsl/operations.rb', line 5 def result=(value) @result = value end |
Instance Method Details
#add_step(name_or_object, args = {}, &block) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# 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 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) ⇒ Object
39 40 41 42 |
# File 'lib/orchestra/dsl/operations.rb', line 39 def operation name = object_name operation [name || operation.result, operation] end |
#build_inline_step(name, block) ⇒ Object
44 45 46 47 |
# 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) ⇒ Object
49 50 51 52 53 |
# 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 ⇒ Object
11 12 13 14 15 16 17 18 19 |
# 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) ⇒ Object
31 32 33 34 35 36 37 |
# 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 |