class Trellohub::List

Public Class Methods

all() click to toggle source
# File lib/trellohub/list.rb, line 30
def all
  @all || self.all!
end
all!() click to toggle source
# File lib/trellohub/list.rb, line 34
def all!
  @all = Trell.lists(Trellohub::Board.id)
end
find_by(id: nil, name: nil) click to toggle source
# File lib/trellohub/list.rb, line 38
def find_by(id: nil, name: nil)
  case
  when !id.nil?
    self.all.find { |list| list.id == id }
  when !name.nil?
    self.all.find { |list| list.name == name }
  else
    nil
  end
end

Public Instance Methods

board_id() click to toggle source
# File lib/trellohub/list.rb, line 25
def board_id
  Trellohub::Board.id
end
find_id() click to toggle source
# File lib/trellohub/list.rb, line 10
def find_id
  current_list = self.class.find_by(name: name)

  list = case
    when current_list && current_list.closed
      Trell.update_list(current_list.id, closed: false)
    when current_list.nil?
      Trell.create_list(name: name, idBoard: board_id)
    else
      current_list
    end

  list.id
end
id() click to toggle source
# File lib/trellohub/list.rb, line 6
def id
  @id ||= find_id
end