module EasyPing::Model::List

Attributes

has_more[R]
has_more?[R]
url[R]

Public Instance Methods

get_next_page() click to toggle source
# File lib/easy_ping/model.rb, line 9
def get_next_page
  raise ParametersInvalid, 'cannot find the last item of this list' unless models.last
  starting_after = models.last.id
  params = extract_params
  params.delete 'ending_before'
  params.merge!({'starting_after' => starting_after})

  action_class.new(config).all(params)
end
get_next_page!() click to toggle source
# File lib/easy_ping/model.rb, line 19
def get_next_page!
  setup(get_next_page.response)
end
get_prev_page() click to toggle source
# File lib/easy_ping/model.rb, line 23
def get_prev_page
  raise ParametersInvalid, 'cannot find the first item of this list' unless models.first
  ending_before = models.first.id
  params = extract_params
  params.delete 'starting_after'
  params.merge!({'ending_before' => ending_before})

  action_class.new(config).all(params)
end
get_prev_page!() click to toggle source
# File lib/easy_ping/model.rb, line 33
def get_prev_page!
  setup(get_prev_page.response)
end

Private Instance Methods

extract_params() click to toggle source
# File lib/easy_ping/model.rb, line 40
def extract_params
  if params = url.match(/(?:\?).+$/)
    params = url.match(/(?:\?).+$/)[0][1..-1]
    CGI::parse params
  else
    {}
  end
end