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
39 40 41 42 |
# File 'lib/trollo/tasklist.rb', line 39 def check check_complete check_due_at end |
#check_complete ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/trollo/tasklist.rb', line 44 def check_complete if complete? undo! if incomplete_tasks.any? elsif incomplete? finish! if incomplete_tasks.none? end end |
#check_due_at ⇒ Object
52 53 54 55 |
# File 'lib/trollo/tasklist.rb', line 52 def check_due_at self.due_at = incomplete_tasks.minimum(:due_at) self.save! end |
#finish_tasks(identifier) ⇒ Object
61 62 63 64 65 |
# File 'lib/trollo/tasklist.rb', line 61 def finish_tasks(identifier) if identifier incomplete_tasks.where(identifier: identifier).each(&:finish!) end end |
#incomplete_tasks ⇒ Object
23 24 25 |
# File 'lib/trollo/tasklist.rb', line 23 def incomplete_tasks tasks.with_incomplete_state end |
#next_task ⇒ Object
35 36 37 |
# File 'lib/trollo/tasklist.rb', line 35 def next_task incomplete_tasks.first end |
#overdue_tasks ⇒ Object
27 28 29 |
# File 'lib/trollo/tasklist.rb', line 27 def overdue_tasks incomplete_tasks.overdue end |
#remove_tasks(identifier) ⇒ Object
67 68 69 70 71 |
# File 'lib/trollo/tasklist.rb', line 67 def remove_tasks(identifier) if identifier tasks.where(identifier: identifier).each(&:destroy) end end |
#set_ordinal ⇒ Object
31 32 33 |
# File 'lib/trollo/tasklist.rb', line 31 def set_ordinal self.ordinal ||= card.tasklists.length + 1 end |
#update_card ⇒ Object
57 58 59 |
# File 'lib/trollo/tasklist.rb', line 57 def update_card card.check end |