Class: Vermonster::Lists::List
- Inherits:
-
Hash
- Object
- Hash
- Vermonster::Lists::List
- Defined in:
- lib/vermonster/lists.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ List
constructor
A new instance of List.
- #tasks ⇒ Object
-
#update(options = {}) ⇒ Object
Note this overrides Hash#update.
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( = {}) self.merge!() .each do |(attr, val)| instance_variable_set("@#{attr}", val) instance_eval "def #{attr}() @#{attr} end" end end |
Class Method Details
.all ⇒ Object
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( = {}) List.new(Vermonster::Client.connection.post("lists", "{\"list\": #{.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
#tasks ⇒ Object
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( = {}) self.merge!(Vermonster::Client.connection.put("lists/#{self["id"]}", "{\"list\": #{.to_json}}").body) end |