Sha256: e54de8353a3285f39f61a200fa46d633e50f1be727b5cfe131b3f61202bdbd1b
Contents?: true
Size: 1.06 KB
Versions: 12
Compression:
Stored size: 1.06 KB
Contents
module StorageRoom # A container object that contains many models (collections or entries) class Array < Resource many :resources # Replaces the objects content with the next page of the array if a next page exists def load_next_page! if self[:@next_page_url].present? reload(self[:@next_page_url]) true else false end end # Replace the Collection with the privious page of elements if there is one def load_previous_page! if self[:@previous_page_url].present? reload(self[:@previous_page_url]) true else false end end # Iterate over all pages def each_page(args={}) begin yield(self) end while(args[:reverse] == true ? load_previous_page! : load_next_page!) end # Iterate over all resources with pagination def each_page_each_item(args={}) self.each_page(args) do |page| page.resources.each do |item| yield(item) end end end end end
Version data entries
12 entries across 12 versions & 1 rubygems