Module: CursorPagination::ActionViewHelper

Included in:
CursorPaginationHelper
Defined in:
lib/cursor_pagination/action_view_helper.rb

Instance Method Summary collapse

Instance Method Details



3
4
5
6
7
8
# File 'lib/cursor_pagination/action_view_helper.rb', line 3

def next_cursor_link(scope, name, params = {}, options = {}, &block)
  url = next_cursor_url(scope, params)
  link_to_unless url.nil?, name, url, options.reverse_merge(:rel => 'next') do
    block.call if block
  end
end

#next_cursor_url(scope, params = {}) ⇒ Object



10
11
12
# File 'lib/cursor_pagination/action_view_helper.rb', line 10

def next_cursor_url(scope, params = {})
  url_for(params.merge(cursor: scope.next_cursor)) unless scope.last_page?
end


14
15
16
17
18
19
# File 'lib/cursor_pagination/action_view_helper.rb', line 14

def previous_cursor_link(scope, name, params = {}, options = {}, &block)
  url = previous_cursor_url(scope, params)
  link_to_unless url.nil?, name, url, options.reverse_merge(:rel => 'previous') do
    block.call if block
  end
end

#previous_cursor_url(scope, params = {}) ⇒ Object



21
22
23
# File 'lib/cursor_pagination/action_view_helper.rb', line 21

def previous_cursor_url(scope, params = {})
  url_for(params.merge(cursor: scope.previous_cursor)) unless scope.first_page?
end