Class: CursorPaginator::OptionsParser
- Inherits:
-
Object
- Object
- CursorPaginator::OptionsParser
- Defined in:
- lib/cursor_paginator/options_parser.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #cursor ⇒ Object
- #cursor_direction ⇒ Object
- #filter_required? ⇒ Boolean
-
#initialize(options = {}) ⇒ OptionsParser
constructor
A new instance of OptionsParser.
- #page_size ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ OptionsParser
Returns a new instance of OptionsParser.
9 10 11 12 |
# File 'lib/cursor_paginator/options_parser.rb', line 9 def initialize( = {}) @options = .deep_dup @options[:size] = normalize_page_size end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/cursor_paginator/options_parser.rb', line 7 def @options end |
Instance Method Details
#cursor ⇒ Object
18 19 20 |
# File 'lib/cursor_paginator/options_parser.rb', line 18 def cursor [:before].presence || [:after].presence end |
#cursor_direction ⇒ Object
22 23 24 |
# File 'lib/cursor_paginator/options_parser.rb', line 22 def cursor_direction (after_direction? ? "after" : "before").inquiry end |
#filter_required? ⇒ Boolean
14 15 16 |
# File 'lib/cursor_paginator/options_parser.rb', line 14 def filter_required? cursor.present? end |
#page_size ⇒ Object
26 27 28 |
# File 'lib/cursor_paginator/options_parser.rb', line 26 def page_size @options[:size] end |