Module: WillPaginate::DataMapper::CollectionMethods
Instance Attribute Summary collapse
Instance Method Summary
collapse
#next_page, #out_of_bounds?, #previous_page, #total_pages
Instance Attribute Details
#current_page ⇒ Object
Returns the value of attribute current_page.
35
36
37
|
# File 'lib/will_paginate/data_mapper.rb', line 35
def current_page
@current_page
end
|
Instance Method Details
#offset ⇒ Object
45
46
47
|
# File 'lib/will_paginate/data_mapper.rb', line 45
def offset
query.offset
end
|
#paginated? ⇒ Boolean
37
38
39
|
# File 'lib/will_paginate/data_mapper.rb', line 37
def paginated?
!current_page.nil?
end
|
#per_page ⇒ Object
41
42
43
|
# File 'lib/will_paginate/data_mapper.rb', line 41
def per_page
query.limit || model.per_page
end
|
#to_a ⇒ Object
63
64
65
66
67
68
|
# File 'lib/will_paginate/data_mapper.rb', line 63
def to_a
::WillPaginate::Collection.create(current_page, per_page) do |col|
col.replace super
col.total_entries ||= total_entries
end
end
|
#total_entries ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/will_paginate/data_mapper.rb', line 49
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
clean_query = query.merge(:order => [])
clean_query.instance_variable_set('@limit', nil)
clean_query.instance_variable_set('@offset', 0)
new_collection(clean_query).count
end
end
end
|