Class: Munson::Paginator::PagedPaginator

Inherits:
Object
  • Object
show all
Defined in:
lib/munson/paginator/paged_paginator.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ PagedPaginator



4
5
6
7
# File 'lib/munson/paginator/paged_paginator.rb', line 4

def initialize(options={})
  @max_size = options[:max]
  @default_size = options[:default]
end

Instance Method Details

#set(opts = {}) ⇒ Object



9
10
11
12
# File 'lib/munson/paginator/paged_paginator.rb', line 9

def set(opts={})
  number(opts[:number]) if opts[:number]
  size(opts[:size]) if opts[:size]
end

#to_paramsObject



14
15
16
17
18
19
20
21
# File 'lib/munson/paginator/paged_paginator.rb', line 14

def to_params
  {
    page: {
      size: @size || @default_size || 10,
      number: @number
    }.select { |_, value| !value.nil? }
  }
end