Sha256: 36910c8e79ce04662a1648f1ac2d611cfa05bff07bddfa2067cbe49a0199484e
Contents?: true
Size: 1.36 KB
Versions: 1
Compression:
Stored size: 1.36 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, ...) @collection.send(method_symbol, ...) end def respond_to_missing?(method_name, include_private = false) super end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
strava-ruby-client-2.2.0 | lib/strava/api/pagination.rb |