Class: GearedPagination::Page
- Inherits:
-
Object
- Object
- GearedPagination::Page
- Defined in:
- lib/geared_pagination/page.rb
Instance Attribute Summary collapse
-
#recordset ⇒ Object
readonly
Returns the value of attribute recordset.
Instance Method Summary collapse
- #before_last? ⇒ Boolean
- #cache_key ⇒ Object
- #empty? ⇒ Boolean
- #first? ⇒ Boolean
-
#initialize(portion, from:) ⇒ Page
constructor
A new instance of Page.
- #last? ⇒ Boolean
- #next_param ⇒ Object (also: #next_number)
- #number ⇒ Object
- #only? ⇒ Boolean
- #records ⇒ Object
- #used? ⇒ Boolean
Constructor Details
#initialize(portion, from:) ⇒ Page
Returns a new instance of Page.
7 8 9 |
# File 'lib/geared_pagination/page.rb', line 7 def initialize(portion, from:) @portion, @recordset = portion, from end |
Instance Attribute Details
#recordset ⇒ Object (readonly)
Returns the value of attribute recordset.
5 6 7 |
# File 'lib/geared_pagination/page.rb', line 5 def recordset @recordset end |
Instance Method Details
#before_last? ⇒ Boolean
41 42 43 |
# File 'lib/geared_pagination/page.rb', line 41 def before_last? number < recordset.page_count end |
#cache_key ⇒ Object
58 59 60 |
# File 'lib/geared_pagination/page.rb', line 58 def cache_key "page/#{@portion.cache_key}" end |
#empty? ⇒ Boolean
24 25 26 |
# File 'lib/geared_pagination/page.rb', line 24 def empty? records.load.none? end |
#first? ⇒ Boolean
29 30 31 |
# File 'lib/geared_pagination/page.rb', line 29 def first? number == 1 end |
#last? ⇒ Boolean
37 38 39 |
# File 'lib/geared_pagination/page.rb', line 37 def last? number == recordset.page_count end |
#next_param ⇒ Object Also known as: next_number
46 47 48 |
# File 'lib/geared_pagination/page.rb', line 46 def next_param @portion.next_param recordset.records end |
#number ⇒ Object
11 12 13 |
# File 'lib/geared_pagination/page.rb', line 11 def number @portion.page_number end |
#only? ⇒ Boolean
33 34 35 |
# File 'lib/geared_pagination/page.rb', line 33 def only? recordset.page_count == 1 end |
#records ⇒ Object
15 16 17 |
# File 'lib/geared_pagination/page.rb', line 15 def records @records ||= @portion.from(recordset.records) end |
#used? ⇒ Boolean
20 21 22 |
# File 'lib/geared_pagination/page.rb', line 20 def used? records.load.any? end |