Class: Orchestra::Node::InlineNode
- Inherits:
-
Orchestra::Node
- Object
- Orchestra::Node
- Orchestra::Node::InlineNode
- Defined in:
- lib/orchestra/node.rb
Defined Under Namespace
Classes: ExecutionContext
Instance Attribute Summary collapse
-
#context_class ⇒ Object
readonly
Returns the value of attribute context_class.
-
#defaults ⇒ Object
readonly
Returns the value of attribute defaults.
-
#perform_block ⇒ Object
readonly
Returns the value of attribute perform_block.
Attributes inherited from Orchestra::Node
#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 = {}) ⇒ InlineNode
constructor
A new instance of InlineNode.
- #optional_dependencies ⇒ Object
- #validate! ⇒ Object
Methods inherited from Orchestra::Node
#collection?, #perform, #process, #required_dependencies
Constructor Details
#initialize(args = {}) ⇒ InlineNode
Returns a new instance of InlineNode.
65 66 67 68 69 70 71 72 |
# File 'lib/orchestra/node.rb', line 65 def initialize args = {} @defaults = args.delete :defaults do {} end @perform_block = args.fetch :perform_block args.delete :perform_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.
63 64 65 |
# File 'lib/orchestra/node.rb', line 63 def context_class @context_class end |
#defaults ⇒ Object (readonly)
Returns the value of attribute defaults.
63 64 65 |
# File 'lib/orchestra/node.rb', line 63 def defaults @defaults end |
#perform_block ⇒ Object (readonly)
Returns the value of attribute perform_block.
63 64 65 |
# File 'lib/orchestra/node.rb', line 63 def perform_block @perform_block end |
Class Method Details
Instance Method Details
#apply_defaults(input) ⇒ Object
94 95 96 97 98 99 100 |
# File 'lib/orchestra/node.rb', line 94 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
89 90 91 92 |
# File 'lib/orchestra/node.rb', line 89 def build_context input state = apply_defaults input execution_context = context_class.new state, perform_block end |
#build_execution_context_class ⇒ Object
80 81 82 83 84 85 86 87 |
# File 'lib/orchestra/node.rb', line 80 def build_execution_context_class context = Class.new ExecutionContext 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
102 103 104 |
# File 'lib/orchestra/node.rb', line 102 def optional_dependencies defaults.keys end |
#validate! ⇒ Object
74 75 76 77 78 |
# File 'lib/orchestra/node.rb', line 74 def validate! unless perform_block raise ArgumentError, "expected inline node to define a perform block" end end |