Class: Trollo::Tasklist
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Trollo::Tasklist
- Includes:
- Troller, Workflow
- Defined in:
- lib/trollo/tasklist.rb
Instance Method Summary collapse
- #check ⇒ Object
- #check_complete ⇒ Object
- #check_due_at ⇒ Object
- #finish_tasks(identifier) ⇒ Object
- #incomplete_tasks ⇒ Object
- #next_task ⇒ Object
- #overdue_tasks ⇒ Object
- #remove_tasks(identifier) ⇒ Object
- #set_ordinal ⇒ Object
- #update_card ⇒ Object
Methods included from Troller
Instance Method Details
#check ⇒ Object
38 39 40 41 |
# File 'lib/trollo/tasklist.rb', line 38 def check check_complete check_due_at end |
#check_complete ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/trollo/tasklist.rb', line 43 def check_complete if complete? undo! if incomplete_tasks.any? elsif incomplete? finish! if incomplete_tasks.none? end end |
#check_due_at ⇒ Object
51 52 53 54 |
# File 'lib/trollo/tasklist.rb', line 51 def check_due_at self.due_at = incomplete_tasks.minimum(:due_at) self.save! end |
#finish_tasks(identifier) ⇒ Object
60 61 62 63 64 |
# File 'lib/trollo/tasklist.rb', line 60 def finish_tasks(identifier) if identifier incomplete_tasks.where(identifier: identifier).each(&:finish!) end end |
#incomplete_tasks ⇒ Object
22 23 24 |
# File 'lib/trollo/tasklist.rb', line 22 def incomplete_tasks tasks.with_incomplete_state end |
#next_task ⇒ Object
34 35 36 |
# File 'lib/trollo/tasklist.rb', line 34 def next_task incomplete_tasks.first end |
#overdue_tasks ⇒ Object
26 27 28 |
# File 'lib/trollo/tasklist.rb', line 26 def overdue_tasks incomplete_tasks.overdue end |
#remove_tasks(identifier) ⇒ Object
66 67 68 69 70 |
# File 'lib/trollo/tasklist.rb', line 66 def remove_tasks(identifier) if identifier tasks.where(identifier: identifier).each(&:destroy) end end |
#set_ordinal ⇒ Object
30 31 32 |
# File 'lib/trollo/tasklist.rb', line 30 def set_ordinal self.ordinal ||= card.tasklists.count + 1 end |
#update_card ⇒ Object
56 57 58 |
# File 'lib/trollo/tasklist.rb', line 56 def update_card card.check end |