Module: Cephalopod::Response::Pagination
- Defined in:
- lib/cephalopod/response.rb
Instance Method Summary collapse
- #get_page(number) ⇒ Object
- #model_parser ⇒ Object
- #next_page ⇒ Object
- #payload ⇒ Object
- #previous_page ⇒ Object
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_parser ⇒ Object
20 21 22 |
# File 'lib/cephalopod/response.rb', line 20 def model_parser payload.map {|x| @repo.model.new(x) } end |
#next_page ⇒ Object
4 5 6 |
# File 'lib/cephalopod/response.rb', line 4 def next_page @repo.get(query: query.merge({ page: @response.body[:page].succ })) end |
#payload ⇒ Object
16 17 18 |
# File 'lib/cephalopod/response.rb', line 16 def payload @response.body[:results] end |
#previous_page ⇒ Object
8 9 10 |
# File 'lib/cephalopod/response.rb', line 8 def previous_page @repo.get(query: query.merge({page: @response.body[:page].pred })) end |