class Restforce::Collection

def each

Yield each value on each page.
def each
  @raw_page['records'].each { |record| yield Restforce::Mash.build(record, @client) }
  next_page.each { |record| yield record } if has_next_page?
end

def has_next_page?

Returns true if there is a pointer to the next page.
def has_next_page?
  !@raw_page['nextRecordsUrl'].nil?
end

def initialize(hash, client)

request Salesforce for the next page of results.
Given a hash and client, will create an Enumerator that will lazily
def initialize(hash, client)
  @client = client
  @raw_page = hash
end

def next_page

Returns the next page as a Restforce::Collection if it's available, nil otherwise.
def next_page
  @next_page ||= @client.get(@raw_page['nextRecordsUrl']).body if has_next_page?
end

def pages

Return the current and all of the following pages.
def pages
  [self] + (has_next_page? ? next_page.pages : [])
end

def size

Return the size of the Collection without making any additional requests.
def size
  @raw_page['totalSize']
end