Module: Apish::Responder::Pagination

Defined in:
lib/apish/responder/pagination.rb

Instance Method Summary collapse

Instance Method Details

#respond(*args) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/apish/responder/pagination.rb', line 3

def respond(*args)
  if paginated?
    controller.headers['X-Total-Entries'] = resource.total_entries.to_s
    controller.headers['X-Total-Pages']   = resource.total_pages.to_s
    controller.headers['X-Current-Page']  = resource.current_page.to_s
    controller.headers['X-Next-Page']     = resource.next_page.to_s
    controller.headers['X-Previous-Page'] = resource.previous_page.to_s
    controller.headers['X-Per-Page']      = resource.per_page.to_s
  end

  super( *args )
end