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



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

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)


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

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

#incomplete_tasksObject



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

def incomplete_tasks
  tasks.with_incomplete_state
end

#overdue_tasksObject



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

def overdue_tasks
  incomplete_tasks.overdue
end

#remove_label(name) ⇒ Object



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

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

#tasksObject



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

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