Module: CursorPagination::ActionViewHelper
- Included in:
- CursorPaginationHelper
- Defined in:
- lib/cursor_pagination/action_view_helper.rb
Instance Method Summary collapse
- #next_cursor_link(scope, name, params = {}, options = {}, &block) ⇒ Object
- #next_cursor_url(scope, params = {}) ⇒ Object
- #previous_cursor_link(scope, name, params = {}, options = {}, &block) ⇒ Object
- #previous_cursor_url(scope, params = {}) ⇒ Object
Instance Method Details
#next_cursor_link(scope, name, params = {}, options = {}, &block) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/cursor_pagination/action_view_helper.rb', line 3 def next_cursor_link(scope, name, params = {}, = {}, &block) url = next_cursor_url(scope, params) link_to_unless url.nil?, name, url, .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 |
#previous_cursor_link(scope, name, params = {}, options = {}, &block) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/cursor_pagination/action_view_helper.rb', line 14 def previous_cursor_link(scope, name, params = {}, = {}, &block) url = previous_cursor_url(scope, params) link_to_unless url.nil?, name, url, .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 |