Module: Metova::Responders::PaginationResponder

Included in:
Metova::Responder
Defined in:
lib/metova/responders/pagination_responder.rb

Instance Method Summary collapse

Instance Method Details

#initializeObject



5
6
7
8
9
10
11
12
13
# File 'lib/metova/responders/pagination_responder.rb', line 5

def initialize(*)
  super
  if response_should_be_paginated?
    @resource = paginate(@resource)
    @links = []
    add_next_to_link_header
    add_last_to_link_header
  end
end

#validate!Object



15
16
17
18
19
20
21
22
# File 'lib/metova/responders/pagination_responder.rb', line 15

def validate!
  if controller.params.include?(:page) && !controller.params.include?(:limit)
    errors << "The 'page' param was sent without 'limit'"
  elsif controller.params.include?(:limit) && !controller.params.include?(:page)
    errors << "The 'limit' param was sent without 'page'"
  end
  super
end