Class: Vermonster::Lists::List

Inherits:
Hash
  • Object
show all
Defined in:
lib/vermonster/lists.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ List

Returns a new instance of List.



8
9
10
11
12
13
14
15
# File 'lib/vermonster/lists.rb', line 8

def initialize(options = {})
  self.merge!(options)

  options.each do |(attr, val)|      
    instance_variable_set("@#{attr}", val)
    instance_eval "def #{attr}() @#{attr} end"
  end
end

Class Method Details

.allObject



27
28
29
30
31
32
33
34
35
# File 'lib/vermonster/lists.rb', line 27

def all
  lists_raw = Vermonster::Client.connection.get("lists").body
  lists = []
  lists_raw.each do |list|
    lists.push(List.new(list))
  end

  lists
end

.create(options = {}) ⇒ Object



41
42
43
# File 'lib/vermonster/lists.rb', line 41

def create(options = {})
  List.new(Vermonster::Client.connection.post("lists", "{\"list\": #{options.to_json}}").body)
end

.find(id) ⇒ Object



37
38
39
# File 'lib/vermonster/lists.rb', line 37

def find(id)
  List.new(Vermonster::Client.connection.get("lists/#{id}").body)
end

.reorder(lists) ⇒ Object



45
46
47
# File 'lib/vermonster/lists.rb', line 45

def reorder(lists)
  
end

Instance Method Details

#tasksObject



22
23
24
# File 'lib/vermonster/lists.rb', line 22

def tasks
  Vermonster::Tasks::Task.from_list(self["id"])
end

#update(options = {}) ⇒ Object

Note this overrides Hash#update. Use Hash#merge! instead.



18
19
20
# File 'lib/vermonster/lists.rb', line 18

def update(options = {})
  self.merge!(Vermonster::Client.connection.put("lists/#{self["id"]}", "{\"list\": #{options.to_json}}").body)
end