Class: Taskflow::Task
- Inherits:
-
Object
show all
- Includes:
- Mongoid::Document
- 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/taskflow/task.rb', line 81
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
33
34
|
# File 'lib/taskflow/task.rb', line 33
def go(sidekiq_logger)
end
|
#resume ⇒ Object
36
37
38
39
40
41
|
# File 'lib/taskflow/task.rb', line 36
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
53
54
55
56
57
58
59
|
# File 'lib/taskflow/task.rb', line 53
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
43
44
45
46
47
48
49
50
51
|
# File 'lib/taskflow/task.rb', line 43
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
|