Class: Taskinator::Process

Inherits:
Object
  • Object
show all
Includes:
Comparable, Persistence, Workflow
Defined in:
lib/taskinator/process.rb

Defined Under Namespace

Classes: Concurrent, Sequential

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Persistence

included

Constructor Details

#initialize(name, definition, options = {}) ⇒ Process

Returns a new instance of Process.

Raises:

  • (ArgumentError)


28
29
30
31
32
33
34
35
36
# File 'lib/taskinator/process.rb', line 28

def initialize(name, definition, options={})
  raise ArgumentError, 'definition' if definition.nil?
  raise ArgumentError, "#{definition.name} does not extend the #{Definition.name} module" unless definition.kind_of?(Definition)

  @uuid = SecureRandom.uuid
  @name = name
  @definition = definition
  @options = options
end

Instance Attribute Details

#definitionObject (readonly)

Returns the value of attribute definition.



22
23
24
# File 'lib/taskinator/process.rb', line 22

def definition
  @definition
end

#nameObject (readonly)

Returns the value of attribute name.



21
22
23
# File 'lib/taskinator/process.rb', line 21

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



23
24
25
# File 'lib/taskinator/process.rb', line 23

def options
  @options
end

#parentObject

in the case of sub process tasks, the containing task



26
27
28
# File 'lib/taskinator/process.rb', line 26

def parent
  @parent
end

#uuidObject (readonly)

Returns the value of attribute uuid.



20
21
22
# File 'lib/taskinator/process.rb', line 20

def uuid
  @uuid
end

Class Method Details

.base_keyObject



15
16
17
# File 'lib/taskinator/process.rb', line 15

def base_key
  'process'
end

.define_concurrent_process_for(name, definition, complete_on = CompleteOn::Default, options = {}) ⇒ Object



11
12
13
# File 'lib/taskinator/process.rb', line 11

def define_concurrent_process_for(name, definition, complete_on=CompleteOn::Default, options={})
  Process::Concurrent.new(name, definition, complete_on, options)
end

.define_sequential_process_for(name, definition, options = {}) ⇒ Object



7
8
9
# File 'lib/taskinator/process.rb', line 7

def define_sequential_process_for(name, definition, options={})
  Process::Sequential.new(name, definition, options)
end

Instance Method Details

#<=>(other) ⇒ Object



51
52
53
# File 'lib/taskinator/process.rb', line 51

def <=>(other)
  uuid <=> other.uuid
end

#accept(visitor) ⇒ Object



42
43
44
45
46
47
48
49
# File 'lib/taskinator/process.rb', line 42

def accept(visitor)
  visitor.visit_attribute(:uuid)
  visitor.visit_task_reference(:parent)
  visitor.visit_attribute(:name)
  visitor.visit_type(:definition)
  visitor.visit_tasks(tasks)
  visitor.visit_args(:options)
end

#enqueueObject



106
107
108
# File 'lib/taskinator/process.rb', line 106

def enqueue
  Taskinator.queue.enqueue_process(self)
end

#on_completed_entry(*args) ⇒ Object

callback for when the process has completed



111
112
113
114
115
# File 'lib/taskinator/process.rb', line 111

def on_completed_entry(*args)
  # notify the parent task (if there is one) that this process has completed
  # note: parent may be a proxy, so explicity check for nil?
  parent.complete! unless parent.nil?
end

#tasksObject



38
39
40
# File 'lib/taskinator/process.rb', line 38

def tasks
  @tasks ||= Tasks.new()
end

#tasks_completed?(*args) ⇒ Boolean

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


96
97
98
99
# File 'lib/taskinator/process.rb', line 96

def tasks_completed?(*args)
  # subclasses must implement this method
  raise NotImplementedError
end

#to_sObject



55
56
57
# File 'lib/taskinator/process.rb', line 55

def to_s
  "#<#{self.class.name}:#{uuid} @name=\"#{name}>\">"
end