Class: Taskflow::Task
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Taskflow::Task
show all
- Defined in:
- lib/taskflow/task.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/taskflow/task.rb', line 67
def method_missing(name,*args)
if /^(set|append|clear)_(input|output|data)$/ =~ name.to_s
act,fd = name.to_s.split '_'
if act == 'set'
return false unless args.first
self.update_attributes! "#{fd}"=>args.first
elsif act == 'append'
return false unless args.first
self.update_attributes! "#{fd}"=>self.send("#{fd}").merge(args.first)
else
self.update_attributes! "#{fd}"=>{}
end
else
super
end
end
|
Instance Method Details
#go(sidekiq_logger) ⇒ Object
18
19
20
|
# File 'lib/taskflow/task.rb', line 18
def go(sidekiq_logger)
raise NotImplementedError
end
|
#resume ⇒ Object
22
23
24
25
26
27
|
# File 'lib/taskflow/task.rb', line 22
def resume
if self.state == 'paused' && self.result == 'error'
self.flow.update_attributes! state: 'running'
Taskflow::Worker.perform_async self.flow.id.to_s,self.id.to_s
end
end
|
#skip ⇒ Object
39
40
41
42
43
44
45
|
# File 'lib/taskflow/task.rb', line 39
def skip
self.reload
if self.state == 'paused'
self.update_attributes! state: 'skipped'
Taskflow::Worker.perform_async self.flow.id.to_s,self.id.to_s
end
end
|
#wakeup(arguments = {}) ⇒ Object
29
30
31
32
33
34
35
36
37
|
# File 'lib/taskflow/task.rb', line 29
def wakeup(arguments={})
self.reload
if self.state == 'paused' && self.result == 'suspend'
self.data = self.data.merge arguments
self.result = nil
self.save
Taskflow::Worker.perform_async self.flow.id.to_s,self.id.to_s
end
end
|