Class: Gearhead::Paginators::Paginator

Inherits:
Object
  • Object
show all
Defined in:
lib/gearhead/paginators/paginator.rb

Direct Known Subclasses

PagyPaginator, WillPaginatePaginator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(records, action) ⇒ Paginator

Returns a new instance of Paginator.



9
10
11
12
13
# File 'lib/gearhead/paginators/paginator.rb', line 9

def initialize(records, action)
  @records = records
  @collection = nil
  @action = action
end

Instance Attribute Details

#collectionObject (readonly)

Returns the value of attribute collection.



8
9
10
# File 'lib/gearhead/paginators/paginator.rb', line 8

def collection
  @collection
end

Class Method Details

.paginate(records, action) ⇒ Object



4
5
6
# File 'lib/gearhead/paginators/paginator.rb', line 4

def self.paginate(records, action)
  ::Gearhead::Paginators::Lookup.for(action).new(records, action)
end

Instance Method Details

#callObject



20
21
22
23
# File 'lib/gearhead/paginators/paginator.rb', line 20

def call
  paginate
  self
end

#paginateObject

should set @collection

Raises:

  • (NotImplementedError)


16
17
18
# File 'lib/gearhead/paginators/paginator.rb', line 16

def paginate
  raise NotImplementedError, "define paginate and set @collection"
end

#serialization_optionsObject



25
26
27
# File 'lib/gearhead/paginators/paginator.rb', line 25

def serialization_options
  {}
end