Class: Trackington::TaskRepository
- Inherits:
-
Object
- Object
- Trackington::TaskRepository
- Defined in:
- lib/trackington/app/tasks.rb
Constant Summary collapse
- STATUSES =
%w(open in_progress resolved closed reopened)
- PRIORITIES =
%w(blocker critical major minor trivial)
- TYPES =
%w(bug improvement new_feature story task)
Instance Method Summary collapse
- #add(data) ⇒ Object
- #all ⇒ Object
- #get(id) ⇒ Object
-
#initialize(sprint_id) ⇒ TaskRepository
constructor
A new instance of TaskRepository.
- #move_to(sprint_id) ⇒ Object
- #priorities ⇒ Object
- #status_types ⇒ Object
- #types ⇒ Object
Constructor Details
#initialize(sprint_id) ⇒ TaskRepository
Returns a new instance of TaskRepository.
9 10 11 |
# File 'lib/trackington/app/tasks.rb', line 9 def initialize(sprint_id) @sprint_id = sprint_id end |
Instance Method Details
#add(data) ⇒ Object
22 23 24 25 26 |
# File 'lib/trackington/app/tasks.rb', line 22 def add(data) data[:sprint_id] = @sprint_id task = Models::Task.new(data) task.save end |
#all ⇒ Object
28 29 30 31 32 |
# File 'lib/trackington/app/tasks.rb', line 28 def all Models::Task.where(sprint_id: @sprint_id).map do |db_task| Task.new(db_task) end end |
#get(id) ⇒ Object
34 35 36 37 |
# File 'lib/trackington/app/tasks.rb', line 34 def get(id) db_task = Models::Task.where(sprint_id: @sprint_id, id: id).first Task.new(db_task) end |
#move_to(sprint_id) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/trackington/app/tasks.rb', line 13 def move_to(sprint_id) tasks = Models::Task.where(sprint_id: sprint_id) tasks.each do |task| task.sprint_id = sprint_id if active?(task.status) task.save end end |
#priorities ⇒ Object
43 44 45 |
# File 'lib/trackington/app/tasks.rb', line 43 def priorities PRIORITIES end |
#status_types ⇒ Object
39 40 41 |
# File 'lib/trackington/app/tasks.rb', line 39 def status_types STATUSES end |
#types ⇒ Object
47 48 49 |
# File 'lib/trackington/app/tasks.rb', line 47 def types TYPES end |