lib/zendesk2/paged_collection.rb in zendesk2-1.3.3 vs lib/zendesk2/paged_collection.rb in zendesk2-1.4.0

- old
+ new

@@ -18,9 +18,27 @@ %w[count next_page_link previous_page_link].each { |k| page.attributes.delete(k) } page.records = [] page end + def each_page + return to_enum(:each_page) unless block_given? + page = self + while page + yield page + page = page.next_page + end + end + + def each_entry + return to_enum(:each_entry) unless block_given? + page = self + while page + page.records.each { |r| yield r } + page = page.next_page + end + end + def next_page new_page.all("url" => next_page_link) if next_page_link end def previous_page