Class: Orchestra::Step::InlineStep
- Inherits:
-
Orchestra::Step
- Object
- Orchestra::Step
- Orchestra::Step::InlineStep
- Defined in:
- lib/orchestra/step.rb
Defined Under Namespace
Classes: InlineContext
Instance Attribute Summary collapse
-
#context_class ⇒ Object
readonly
Returns the value of attribute context_class.
-
#defaults ⇒ Object
readonly
Returns the value of attribute defaults.
-
#execute_block ⇒ Object
readonly
Returns the value of attribute execute_block.
Attributes inherited from Orchestra::Step
#collection, #dependencies, #provisions
Class Method Summary collapse
Instance Method Summary collapse
- #apply_defaults(input) ⇒ Object
- #build_context(input) ⇒ Object
- #build_execution_context_class ⇒ Object
-
#initialize(args = {}) ⇒ InlineStep
constructor
A new instance of InlineStep.
- #optional_dependencies ⇒ Object
- #validate! ⇒ Object
Methods inherited from Orchestra::Step
#collection?, #execute, #process, #required_dependencies
Constructor Details
#initialize(args = {}) ⇒ InlineStep
Returns a new instance of InlineStep.
62 63 64 65 66 67 68 69 |
# File 'lib/orchestra/step.rb', line 62 def initialize args = {} @defaults = args.delete :defaults do {} end @execute_block = args.fetch :execute_block args.delete :execute_block super args @context_class = build_execution_context_class validate! end |
Instance Attribute Details
#context_class ⇒ Object (readonly)
Returns the value of attribute context_class.
60 61 62 |
# File 'lib/orchestra/step.rb', line 60 def context_class @context_class end |
#defaults ⇒ Object (readonly)
Returns the value of attribute defaults.
60 61 62 |
# File 'lib/orchestra/step.rb', line 60 def defaults @defaults end |
#execute_block ⇒ Object (readonly)
Returns the value of attribute execute_block.
60 61 62 |
# File 'lib/orchestra/step.rb', line 60 def execute_block @execute_block end |
Class Method Details
Instance Method Details
#apply_defaults(input) ⇒ Object
91 92 93 94 95 96 97 |
# File 'lib/orchestra/step.rb', line 91 def apply_defaults input defaults.each do |key, thunk| next if input.has_key? key input[key] = thunk.call end input end |
#build_context(input) ⇒ Object
86 87 88 89 |
# File 'lib/orchestra/step.rb', line 86 def build_context input state = apply_defaults input execution_context = context_class.new state, execute_block end |
#build_execution_context_class ⇒ Object
77 78 79 80 81 82 83 84 |
# File 'lib/orchestra/step.rb', line 77 def build_execution_context_class context = Class.new InlineContext context.class_exec dependencies, collection do |deps, collection| deps.each do |dep| define_dependency dep end alias_method :fetch_collection, collection if collection end context end |
#optional_dependencies ⇒ Object
99 100 101 |
# File 'lib/orchestra/step.rb', line 99 def optional_dependencies defaults.keys end |
#validate! ⇒ Object
71 72 73 74 75 |
# File 'lib/orchestra/step.rb', line 71 def validate! unless execute_block raise ArgumentError, "expected inline step to define a execute block" end end |