class Gearhead::Paginators::Paginator

Attributes

collection[R]

Public Class Methods

new(records, action) click to toggle source
# File lib/gearhead/paginators/paginator.rb, line 9
def initialize(records, action)
  @records = records
  @collection = nil
  @action = action
end
paginate(records, action) click to toggle source
# File lib/gearhead/paginators/paginator.rb, line 4
def self.paginate(records, action)
  ::Gearhead::Paginators::Lookup.for(action).new(records, action)
end

Public Instance Methods

call() click to toggle source
# File lib/gearhead/paginators/paginator.rb, line 20
def call
  paginate
  self
end
paginate() click to toggle source

should set @collection

# File lib/gearhead/paginators/paginator.rb, line 16
def paginate
  raise NotImplementedError, "define paginate and set @collection"
end
serialization_options() click to toggle source
# File lib/gearhead/paginators/paginator.rb, line 25
def serialization_options
  {}
end

Private Instance Methods

gear() click to toggle source
# File lib/gearhead/paginators/paginator.rb, line 39
def gear
  @action.gear
end
page() click to toggle source
# File lib/gearhead/paginators/paginator.rb, line 35
def page
  request.params[:page] || 1
end
per_page() click to toggle source
# File lib/gearhead/paginators/paginator.rb, line 31
def per_page
  gear._gear_per_page
end
request() click to toggle source
# File lib/gearhead/paginators/paginator.rb, line 43
def request
  @action.request
end