Class: Folio::WillPaginate::ActiveRecord::Pagination::PageProxy

Inherits:
Object
  • Object
show all
Includes:
Ordinal::Page
Defined in:
lib/folio/will_paginate/active_record.rb

Overview

turns the sequence of calls made by Folio::Ordinal#paginate into the construction of an appropriate relation

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Ordinal::Page

create, #first_page, #last_page, #next_page, #next_page=, #offset, #ordinal_pages, #previous_page

Constructor Details

#initialize(target) ⇒ PageProxy

Returns a new instance of PageProxy.



59
60
61
# File 'lib/folio/will_paginate/active_record.rb', line 59

def initialize(target)
  @target = target
end

Instance Attribute Details

#current_pageObject

called during Folio::Ordinal#configure_pagination for bounds checking, before the proxy has been replaced by its result



80
81
82
# File 'lib/folio/will_paginate/active_record.rb', line 80

def current_page
  @rel.current_page
end

Instance Method Details

#out_of_bounds?Boolean

Returns:

  • (Boolean)


84
85
86
# File 'lib/folio/will_paginate/active_record.rb', line 84

def out_of_bounds?
  @rel.out_of_bounds?
end

#per_page=(per_page) ⇒ Object



69
70
71
72
# File 'lib/folio/will_paginate/active_record.rb', line 69

def per_page=(per_page)
  @rel = @target.limit(per_page.to_i).page(@current_page)
  @rel.limit_value
end

#resultObject

get the result of the construction back out during fill_page



89
90
91
# File 'lib/folio/will_paginate/active_record.rb', line 89

def result
  @rel
end

#total_entries=(total_entries) ⇒ Object



74
75
76
# File 'lib/folio/will_paginate/active_record.rb', line 74

def total_entries=(total_entries)
  @rel.total_entries = total_entries
end