Module: Fluent::Workflow
- Included in:
- Factory
- Defined in:
- lib/fluent/workflows.rb
Class Method Summary collapse
Instance Method Summary collapse
- #perform_workflow(definitions) ⇒ Object
- #work_item_index_for(path_workflow, definition) ⇒ Object
-
#workflow_for(definition, path_name = {:using => :default}, &block) ⇒ Object
This provides a workflow for a given workflow path, using a specific definition that is part of that workflow path.
- #workflow_path_for(path_name) ⇒ Object
Class Method Details
.def_caller ⇒ Object
20 21 22 |
# File 'lib/fluent/workflows.rb', line 20 def self.def_caller @def_caller end |
.included(caller) ⇒ Object
14 15 16 17 18 |
# File 'lib/fluent/workflows.rb', line 14 def self.included(caller) Fluent.trace("#{caller.class} #{caller} is using workflows.") caller.extend WorkflowPaths @def_caller = caller end |
Instance Method Details
#perform_workflow(definitions) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/fluent/workflows.rb', line 62 def perform_workflow(definitions) definitions.each do |definition, action, *args| active = on(definition) raise Fluent::Errors::WorkflowActionNotFound, "Workflow action '#{action}' not defined on #{definition}." unless active.respond_to? action active.send action unless args active.send action, *args if args end end |
#work_item_index_for(path_workflow, definition) ⇒ Object
58 59 60 |
# File 'lib/fluent/workflows.rb', line 58 def work_item_index_for(path_workflow, definition) path_workflow.find_index { |item| item[0] == definition } end |
#workflow_for(definition, path_name = {:using => :default}, &block) ⇒ Object
This provides a workflow for a given workflow path, using a specific definition that is part of that workflow path.
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/fluent/workflows.rb', line 31 def workflow_for(definition, path_name = {:using => :default}, &block) path_name[:using] = :default unless path_name[:using] path_workflow = workflow_path_for(path_name) workflow_goal = work_item_index_for(path_workflow, definition) workflow_start = path_name[:from] ? path_workflow.find_index { |item| item[0] == path_name[:from]} : 0 perform_workflow(path_workflow[workflow_start..workflow_goal]) on(definition, &block) end |
#workflow_path_for(path_name) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/fluent/workflows.rb', line 45 def workflow_path_for(path_name) # Since I am dealing with an array that contains a hash that, in # turn, contains an array of arrays, below I need to make sure I # index into the array before keying into the hash. That's the # purpose of the [0]. path = Workflow.def_caller.paths[0][path_name[:using]] raise Fluent::Errors::WorkflowPathNotFound, "Workflow path '#{path_name[:using].to_s}' not found." unless path path end |