Module: Cephalopod::Response::Pagination

Defined in:
lib/cephalopod/response.rb

Instance Method Summary collapse

Instance Method Details

#get_page(number) ⇒ Object



12
13
14
# File 'lib/cephalopod/response.rb', line 12

def get_page(number)
  @repo.get(query: query.merge({page: number}))
end

#model_parserObject



20
21
22
# File 'lib/cephalopod/response.rb', line 20

def model_parser
  payload.map {|x| @repo.model.new(x) } 
end

#next_pageObject



4
5
6
# File 'lib/cephalopod/response.rb', line 4

def next_page
  @repo.get(query: query.merge({ page: @response.body[:page].succ }))
end

#payloadObject



16
17
18
# File 'lib/cephalopod/response.rb', line 16

def payload
  @response.body[:results]
end

#previous_pageObject



8
9
10
# File 'lib/cephalopod/response.rb', line 8

def previous_page
  @repo.get(query: query.merge({page: @response.body[:page].pred }))
end