Class: Seam::Effort
- Inherits:
-
Object
- Object
- Seam::Effort
- Defined in:
- lib/seam/effort.rb
Instance Attribute Summary collapse
-
#complete ⇒ Object
Returns the value of attribute complete.
-
#completed_at ⇒ Object
Returns the value of attribute completed_at.
-
#completed_steps ⇒ Object
Returns the value of attribute completed_steps.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#data ⇒ Object
Returns the value of attribute data.
-
#flow ⇒ Object
Returns the value of attribute flow.
-
#history ⇒ Object
Returns the value of attribute history.
-
#id ⇒ Object
Returns the value of attribute id.
-
#next_execute_at ⇒ Object
Returns the value of attribute next_execute_at.
-
#next_step ⇒ Object
Returns the value of attribute next_step.
Class Method Summary collapse
- .create(args) ⇒ Object
- .find(effort_id) ⇒ Object
- .find_all_by_step(step) ⇒ Object
- .parse(document) ⇒ Object
Instance Method Summary collapse
- #clone ⇒ Object
- #complete? ⇒ Boolean
-
#initialize(args = {}) ⇒ Effort
constructor
A new instance of Effort.
- #save ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Effort
Returns a new instance of Effort.
41 42 43 44 45 46 |
# File 'lib/seam/effort.rb', line 41 def initialize(args = {}) @completed_steps = [] @history = [] @complete = false args.each { |k, v| self.send "#{k}=".to_sym, v } end |
Instance Attribute Details
#complete ⇒ Object
Returns the value of attribute complete.
5 6 7 |
# File 'lib/seam/effort.rb', line 5 def complete @complete end |
#completed_at ⇒ Object
Returns the value of attribute completed_at.
6 7 8 |
# File 'lib/seam/effort.rb', line 6 def completed_at @completed_at end |
#completed_steps ⇒ Object
Returns the value of attribute completed_steps.
3 4 5 |
# File 'lib/seam/effort.rb', line 3 def completed_steps @completed_steps end |
#created_at ⇒ Object
Returns the value of attribute created_at.
4 5 6 |
# File 'lib/seam/effort.rb', line 4 def created_at @created_at end |
#data ⇒ Object
Returns the value of attribute data.
11 12 13 |
# File 'lib/seam/effort.rb', line 11 def data @data end |
#flow ⇒ Object
Returns the value of attribute flow.
10 11 12 |
# File 'lib/seam/effort.rb', line 10 def flow @flow end |
#history ⇒ Object
Returns the value of attribute history.
12 13 14 |
# File 'lib/seam/effort.rb', line 12 def history @history end |
#id ⇒ Object
Returns the value of attribute id.
7 8 9 |
# File 'lib/seam/effort.rb', line 7 def id @id end |
#next_execute_at ⇒ Object
Returns the value of attribute next_execute_at.
8 9 10 |
# File 'lib/seam/effort.rb', line 8 def next_execute_at @next_execute_at end |
#next_step ⇒ Object
Returns the value of attribute next_step.
9 10 11 |
# File 'lib/seam/effort.rb', line 9 def next_step @next_step end |
Class Method Details
.create(args) ⇒ Object
48 49 50 51 52 |
# File 'lib/seam/effort.rb', line 48 def self.create args effort = Seam::Effort.new args effort.save effort end |
.find(effort_id) ⇒ Object
16 17 18 |
# File 'lib/seam/effort.rb', line 16 def find effort_id Seam::Persistence.find_by_effort_id effort_id end |
.find_all_by_step(step) ⇒ Object
20 21 22 |
# File 'lib/seam/effort.rb', line 20 def find_all_by_step step Seam::Persistence.find_all_pending_executions_by_step step end |
.parse(document) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/seam/effort.rb', line 24 def parse document Effort.new( { id: document['id'], created_at: Time.parse(document['created_at'].to_s), next_execute_at: document['next_execute_at'], next_step: document['next_step'], flow: HashWithIndifferentAccess.new(document['flow']), data: HashWithIndifferentAccess.new(document['data']), history: document['history'].map { |x| HashWithIndifferentAccess.new x }, completed_steps: document['completed_steps'], complete: document['complete'], completed_at: document['completed_at'] } ) end |
Instance Method Details
#clone ⇒ Object
82 83 84 |
# File 'lib/seam/effort.rb', line 82 def clone Seam::Effort.parse HashWithIndifferentAccess.new(self.to_hash) end |
#complete? ⇒ Boolean
63 64 65 |
# File 'lib/seam/effort.rb', line 63 def complete? complete end |
#save ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/seam/effort.rb', line 54 def save existing_record = Seam::Effort.find self.id if existing_record Seam::Persistence.save self else Seam::Persistence.create self end end |
#to_hash ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/seam/effort.rb', line 67 def to_hash { id: self.id, created_at: self.created_at, completed_steps: self.completed_steps, completed_at: self.completed_at, next_execute_at: self.next_execute_at, next_step: self.next_step, flow: self.flow, data: self.data, history: self.history, complete: self.complete, } end |