Sha256: 4e27eb1ab951318638cae11c701e70588cfb9ed8b59a7942d883c6e9e3bf9e45
Contents?: true
Size: 588 Bytes
Versions: 38
Compression:
Stored size: 588 Bytes
Contents
module RestfulResource class PaginatedArray < Array def initialize(original_array, previous_page_url: previous_page_url, next_page_url: next_page_url) super(original_array) @previous_page_url = previous_page_url @next_page_url = next_page_url end def previous_page get_page_from_url(@previous_page_url) end def next_page get_page_from_url(@next_page_url) end private def get_page_from_url(url) return nil unless url params = Rack::Utils.parse_query URI(url).query params['page'].to_i end end end
Version data entries
38 entries across 38 versions & 1 rubygems