Class: Munson::Paginator::OffsetPaginator
- Inherits:
-
Object
- Object
- Munson::Paginator::OffsetPaginator
- Defined in:
- lib/munson/paginator/offset_paginator.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ OffsetPaginator
constructor
A new instance of OffsetPaginator.
- #set(opts = {}) ⇒ Object
- #to_params ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ OffsetPaginator
Returns a new instance of OffsetPaginator.
4 5 6 7 |
# File 'lib/munson/paginator/offset_paginator.rb', line 4 def initialize(={}) @max_limit = [:max] @default_limit = [:default] end |
Instance Method Details
#set(opts = {}) ⇒ Object
9 10 11 12 |
# File 'lib/munson/paginator/offset_paginator.rb', line 9 def set(opts={}) limit(opts[:limit]) if opts[:limit] offset(opts[:offset]) if opts[:offset] end |
#to_params ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/munson/paginator/offset_paginator.rb', line 14 def to_params { page: { limit: @limit || @default_limit || 10, offset: @offset }.select { |_, value| !value.nil? } } end |