Sha256: 4e2523d9bafcdd31c1a92bf28762f0e8a416d709fd744bd6ece0d5f933e88705
Contents?: true
Size: 1.38 KB
Versions: 5
Compression:
Stored size: 1.38 KB
Contents
# frozen_string_literal: true module Strava module Api # # Wrapper Class around pagination results which are an Array of Models. # # This class exists to provide a way to provide a high-level abstraction, like # access to API request/response data (i.e. ratelimits) for paginated results. # class Pagination include Enumerable include Strava::DeepCopyable attr_reader :collection # # @param [Array<Strava::Models::>] collection of Models # @param [Strava::Web::Response] web_response # def initialize(collection, web_response) @collection = collection @web_response = web_response end # # getter method that calculates on access # # @return [Strava::Web::ApiResponse] # def http_response @http_response ||= Strava::Web::ApiResponse.new(deep_copy(@web_response).http_response) end # # delegates `size` to @collection # # @return [Integer] # def size @collection.size end def each @collection.each { |c| yield c if block_given? } end private def method_missing(method_symbol, *args, &block) @collection.send(method_symbol, *args, &block) end def respond_to_missing?(method_name, include_private = false) super end end end end
Version data entries
5 entries across 5 versions & 1 rubygems