class Fulfillment::PagedResult
Attributes
first_page_num[R]
Public Class Methods
construct(first_page_num, &api_caller_proc)
click to toggle source
Alternative constructor that takes a block rather than a Proc instance
# File lib/fulfillment/paged_result.rb, line 40 def construct(first_page_num, &api_caller_proc) new(first_page_num, api_caller_proc) end
new(first_page_num, api_caller_proc)
click to toggle source
first_page_number is the starting page for the associated API call. api_caller_proc is a Proc that returns a hash (of the type returned
by Exchange::PagingEnvelope.envelope). Calling the proc and passing it a page_number should return an enveloped API call result.
# File lib/fulfillment/paged_result.rb, line 13 def initialize(first_page_num, api_caller_proc) @first_page_num = first_page_num @api_caller_proc = api_caller_proc end
Public Instance Methods
each() { |enveloped_page| ... }
click to toggle source
# File lib/fulfillment/paged_result.rb, line 26 def each page_num = @first_page_num enveloped_page = @api_caller_proc.call(page_num) yield enveloped_page[:data] while (page_num < enveloped_page[:total_pages]) page_num += 1 enveloped_page = @api_caller_proc.call(page_num) yield enveloped_page[:data] end end
pages()
click to toggle source
# File lib/fulfillment/paged_result.rb, line 18 def pages entries end
results()
click to toggle source
# File lib/fulfillment/paged_result.rb, line 22 def results pages.flatten end