Class: Pallets::Workflow

Inherits:
Object
  • Object
show all
Extended by:
DSL::Workflow
Defined in:
lib/pallets/workflow.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from DSL::Workflow

task

Constructor Details

#initialize(context_hash = {}) ⇒ Workflow

Returns a new instance of Workflow.



7
8
9
10
11
# File 'lib/pallets/workflow.rb', line 7

def initialize(context_hash = {})
  @id = nil
  # Passed in context hash needs to be buffered
  @context = Context.new.merge!(context_hash)
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



5
6
7
# File 'lib/pallets/workflow.rb', line 5

def context
  @context
end

Instance Method Details

#idObject



21
22
23
# File 'lib/pallets/workflow.rb', line 21

def id
  @id ||= "P#{Pallets::Util.generate_id(self.class.name)}".upcase
end

#runObject

Raises:



13
14
15
16
17
18
19
# File 'lib/pallets/workflow.rb', line 13

def run
  raise WorkflowError, "#{self.class.name} has no tasks. Workflows "\
                       "must contain at least one task" if self.class.graph.empty?

  backend.run_workflow(id, jobs_with_order, serializer.dump_context(context.buffer))
  id
end