Module: ActiveRecordCursorPaginate::Extension

Defined in:
lib/activerecord_cursor_paginate/extension.rb

Instance Method Summary collapse

Instance Method Details

#cursor_paginate(after: nil, before: nil, limit: nil, order: nil, append_primary_key: true) ⇒ ActiveRecordCursorPaginate::Paginator Also known as: cursor_pagination

Convenient method to use on ActiveRecord::Relation to get a paginator.

Examples:

paginator = Post.cursor_paginate(limit: 2, after: "Mg")
page = paginator.fetch

Returns:

See Also:



13
14
15
16
# File 'lib/activerecord_cursor_paginate/extension.rb', line 13

def cursor_paginate(after: nil, before: nil, limit: nil, order: nil, append_primary_key: true)
  relation = (is_a?(ActiveRecord::Relation) ? self : all)
  Paginator.new(relation, after: after, before: before, limit: limit, order: order, append_primary_key: append_primary_key)
end