class Rjawbone::Model::List

Attributes

collection[R]
next[R]
page_token[R]
size[R]
user_xid[R]

Public Class Methods

new(response) click to toggle source
Calls superclass method Rjawbone::Model::Base::new
# File lib/rjawbone/models/list.rb, line 9
def initialize(response)
  return unless response["data"] && response["meta"]
  super(response)
  @user_xid = response["meta"]["user_xid"]
  @size = response["data"]["size"]
  if response["data"]["links"]
    next_link = response["data"]["links"]["next"]
    @next = Rjawbone::JAWBONE_URL + next_link 
  end
  @collection = response["data"]["items"].map do |item|
    item.merge!({"client" => response["client"]}) if response["client"]
    Item.new(item)
  end
end

Public Instance Methods

each(&block) click to toggle source
# File lib/rjawbone/models/list.rb, line 28
def each(&block)
  collection.each(&block)
end
next_page() click to toggle source
# File lib/rjawbone/models/list.rb, line 24
def next_page
  client.get_object(@next, self.class) if @next
end