class SentryApi::PaginatedResponse
Wrapper class of paginated response.
Attributes
client[RW]
Public Class Methods
new(array)
click to toggle source
# File lib/sentry-api/paginated_response.rb, line 6 def initialize(array) @array = array end
Public Instance Methods
==(other)
click to toggle source
# File lib/sentry-api/paginated_response.rb, line 10 def ==(other) @array == other end
auto_paginate() { |item| ... }
click to toggle source
# File lib/sentry-api/paginated_response.rb, line 43 def auto_paginate response = block_given? ? nil : [] each_page do |page| if block_given? page.each do |item| yield item end else response += page end end response end
each_page() { |current| ... }
click to toggle source
# File lib/sentry-api/paginated_response.rb, line 34 def each_page current = self yield current while current.has_next_page? current = current.next_page yield current end end
has_next_page?()
click to toggle source
# File lib/sentry-api/paginated_response.rb, line 57 def has_next_page? !(@links.nil? || @links.next.nil?) end
has_prev_page?()
click to toggle source
# File lib/sentry-api/paginated_response.rb, line 67 def has_prev_page? !(@links.nil? || @links.previous.nil?) end
inspect()
click to toggle source
# File lib/sentry-api/paginated_response.rb, line 14 def inspect @array.inspect end
method_missing(name, *args, &block)
click to toggle source
Calls superclass method
# File lib/sentry-api/paginated_response.rb, line 18 def method_missing(name, *args, &block) if @array.respond_to?(name) @array.send(name, *args, &block) else super end end
next_page()
click to toggle source
# File lib/sentry-api/paginated_response.rb, line 61 def next_page return nil if @client.nil? || !has_next_page? path = @links.next.sub(/#{@client.endpoint}/, '') @client.get(path) end
parse_headers!(headers)
click to toggle source
# File lib/sentry-api/paginated_response.rb, line 30 def parse_headers!(headers) @links = PageLinks.new headers end
prev_page()
click to toggle source
# File lib/sentry-api/paginated_response.rb, line 71 def prev_page return nil if @client.nil? || !has_prev_page? path = @links.previous.sub(/#{@client.endpoint}/, '') @client.get(path) end
respond_to_missing?(method_name, include_private = false)
click to toggle source
Calls superclass method
# File lib/sentry-api/paginated_response.rb, line 26 def respond_to_missing?(method_name, include_private = false) super || @array.respond_to?(method_name, include_private) end