class GitlabRuby::PaginatedResponse

Public Class Methods

new(params = {}) click to toggle source
# File lib/gitlab_ruby/paginated_response.rb, line 5
def initialize(params = {})
  @client = params[:client]
  @array = params[:array]
  @page_links = parse_page_links_from(params[:headers])
end

Public Instance Methods

==(other) click to toggle source

Treat this like an Array (START)

# File lib/gitlab_ruby/paginated_response.rb, line 41
def ==(other)
  @array == other
end
first_page() click to toggle source
# File lib/gitlab_ruby/paginated_response.rb, line 35
def first_page
  fetch(@page_links['first'][:href])
end
inspect() click to toggle source
# File lib/gitlab_ruby/paginated_response.rb, line 45
def inspect
  @array.inspect
end
last_page() click to toggle source
# File lib/gitlab_ruby/paginated_response.rb, line 31
def last_page
  fetch(@page_links['last'][:href])
end
method_missing(name, *args, &block) click to toggle source
Calls superclass method
# File lib/gitlab_ruby/paginated_response.rb, line 49
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/gitlab_ruby/paginated_response.rb, line 21
def next_page
  return nil unless next_page?
  fetch(@page_links['next'][:href])
end
next_page?() click to toggle source
# File lib/gitlab_ruby/paginated_response.rb, line 11
def next_page?
  return nil unless @page_links['next']
  true
end
prev_page() click to toggle source
# File lib/gitlab_ruby/paginated_response.rb, line 26
def prev_page
  return nil unless prev_page?
  fetch(@page_links['prev'][:href])
end
prev_page?() click to toggle source
# File lib/gitlab_ruby/paginated_response.rb, line 16
def prev_page?
  return nil unless @page_links['prev']
  true
end
respond_to_missing?(method_name, include_private = false) click to toggle source
Calls superclass method
# File lib/gitlab_ruby/paginated_response.rb, line 57
def respond_to_missing?(method_name, include_private = false)
  super || @array.respond_to?(method_name, include_private)
end

Private Instance Methods

fetch(href) click to toggle source
# File lib/gitlab_ruby/paginated_response.rb, line 72
def fetch(href)
  query_chain = GitlabRuby::QueryChain.new(client: @client, verb: :get)
  query_chain.urlstring = href
  query_chain.execute
end