Class: Pagination::OhmAdapter

Inherits:
Collection show all
Defined in:
lib/pagination/adapters/ohm.rb

Constant Summary

Constants inherited from Collection

Collection::Unimplemented

Instance Attribute Summary

Attributes inherited from Collection

#page, #per_page, #total

Instance Method Summary collapse

Methods inherited from Collection

#current?, #displayed_pages, #each, #next_page, #prev_page, #render?, #total_pages

Constructor Details

#initialize(dataset, options = {}) ⇒ OhmAdapter

Returns a new instance of OhmAdapter.



3
4
5
6
7
8
9
10
11
# File 'lib/pagination/adapters/ohm.rb', line 3

def initialize(dataset, options = {})
  super

  @dataset = dataset
  @total   = dataset.size
  @sort_by = options[:sort_by]
  @order   = options[:order]
  @start   = (page - 1) * per_page
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/pagination/adapters/ohm.rb', line 13

def empty?
  @total.zero?
end