module WillPaginate::DataMapper::CollectionMethods
Attributes
Public Instance Methods
Source
# File lib/will_paginate/data_mapper.rb, line 42 def paginated? !current_page.nil? end
Source
# File lib/will_paginate/data_mapper.rb, line 46 def per_page query.limit || model.per_page end
Source
# File lib/will_paginate/data_mapper.rb, line 70 def to_a if paginated? ::WillPaginate::Collection.create(current_page, per_page) do |col| col.replace super col.total_entries ||= total_entries end else super end end
Calls superclass method
Source
# File lib/will_paginate/data_mapper.rb, line 54 def total_entries @total_entries ||= begin if loaded? and @array.size < per_page and (current_page == 1 or @array.size > 0) offset + @array.size else # :reload prevents Collection.filter from being run, which # would cause a stack overflow clean_query = query.merge(:reload => true) # seems like the only way clean_query.instance_variable_set('@limit', nil) clean_query.instance_variable_set('@offset', 0) new_collection(clean_query).count end end end
Private Instance Methods
Source
# File lib/will_paginate/data_mapper.rb, line 89 def initialize_copy(original) super @total_entries = nil end
Calls superclass method
Source
# File lib/will_paginate/data_mapper.rb, line 83 def new_collection(query, resources = nil) col = super col.current_page = self.current_page col end
Calls superclass method