Class: Trollo::Board

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/trollo/board.rb

Instance Method Summary collapse

Instance Method Details

#add_label(name) ⇒ Object



23
24
25
26
27
# File 'lib/trollo/board.rb', line 23

def add_label(name)
  return if has_label?(name)
  label = Label.where(name: name).first || Label.create!(name: name)
  self.labels << label
end

#has_label?(name) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/trollo/board.rb', line 33

def has_label?(name)
  labels.pluck(:name).include?(name)
end

#incomplete_tasksObject



15
16
17
# File 'lib/trollo/board.rb', line 15

def incomplete_tasks
  tasks.with_incomplete_state
end

#overdue_tasksObject



19
20
21
# File 'lib/trollo/board.rb', line 19

def overdue_tasks
  incomplete_tasks.overdue
end

#remove_label(name) ⇒ Object



29
30
31
# File 'lib/trollo/board.rb', line 29

def remove_label(name)
  self.labels -= Label.where(name: name)
end

#tasksObject



9
10
11
12
13
# File 'lib/trollo/board.rb', line 9

def tasks
  card_ids = Trollo::Card.where(list_id: list_ids).pluck(:id)
  tasklist_ids = Trollo::Tasklist.where(card_id: card_ids).pluck(:id)
  Trollo::Task.where(tasklist_id: tasklist_ids)
end