Class: CursorPaginator::Paginator::Base
- Inherits:
-
Object
- Object
- CursorPaginator::Paginator::Base
- Defined in:
- lib/cursor_paginator/paginator/base.rb
Direct Known Subclasses
Constant Summary collapse
- SORT_DIRECTIONS =
%i[asc desc].freeze
Instance Attribute Summary collapse
-
#options_parser ⇒ Object
readonly
Returns the value of attribute options_parser.
-
#paginator_options ⇒ Object
readonly
Returns the value of attribute paginator_options.
Instance Method Summary collapse
-
#initialize(page_options: {}, paginator_options: {}) ⇒ Base
constructor
A new instance of Base.
- #take_records(records, limit) ⇒ Object
Constructor Details
#initialize(page_options: {}, paginator_options: {}) ⇒ Base
Returns a new instance of Base.
9 10 11 12 13 14 15 16 |
# File 'lib/cursor_paginator/paginator/base.rb', line 9 def initialize(page_options: {}, paginator_options: {}) @options_parser = OptionsParser.new() @paginator_options = .reverse_merge( order_key: :id, primary_key: :id, sort_direction: :desc ) end |
Instance Attribute Details
#options_parser ⇒ Object (readonly)
Returns the value of attribute options_parser.
6 7 8 |
# File 'lib/cursor_paginator/paginator/base.rb', line 6 def @options_parser end |
#paginator_options ⇒ Object (readonly)
Returns the value of attribute paginator_options.
6 7 8 |
# File 'lib/cursor_paginator/paginator/base.rb', line 6 def @paginator_options end |
Instance Method Details
#take_records(records, limit) ⇒ Object
18 19 20 |
# File 'lib/cursor_paginator/paginator/base.rb', line 18 def take_records(records, limit) records.take(limit) end |