folio-pagination 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/folio.rb +12 -1
- data/lib/folio/version.rb +1 -1
- data/lib/folio/will_paginate/active_record.rb +13 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 832b40bbfc520a630238027b81a611c1a503a6bf
|
4
|
+
data.tar.gz: 5f3b9010512ece27b16eb4542824216388cbbdaa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d86e58bd0076d1754ff9ca084a411445634607997d2af0027099730dd437213df7c5a44e8b20b4094a2c3a1d49cd265a52b3b97c37855fdf5dded0f538636fbd
|
7
|
+
data.tar.gz: 62197be67cf3966aa7ccf28830fcccf47570bbea7525b5dbc22ae15c147917bb76ce83acb0847137b277d85c35a4a8deb4e95ec26fc442065664d12c74ace5bd
|
data/lib/folio.rb
CHANGED
@@ -49,7 +49,18 @@ module Folio
|
|
49
49
|
current_page = page.first_page if current_page.nil?
|
50
50
|
page.current_page = current_page
|
51
51
|
page.per_page = options[:per_page] || self.per_page
|
52
|
-
|
52
|
+
|
53
|
+
page.total_entries = options.fetch(:total_entries) do
|
54
|
+
if self.respond_to?(:count)
|
55
|
+
if self.is_a?(::ActiveRecord::Relation) && ::Rails.version >= '4'
|
56
|
+
self.count(:all)
|
57
|
+
else
|
58
|
+
self.count
|
59
|
+
end
|
60
|
+
else
|
61
|
+
nil
|
62
|
+
end
|
63
|
+
end
|
53
64
|
page
|
54
65
|
end
|
55
66
|
|
data/lib/folio/version.rb
CHANGED
@@ -116,19 +116,28 @@ module Folio
|
|
116
116
|
|
117
117
|
def paginate(options={})
|
118
118
|
if !options.has_key?(:total_entries)
|
119
|
-
|
119
|
+
scope = if ::Rails.version < '4'
|
120
|
+
self.scoped
|
121
|
+
elsif self.is_a?(::ActiveRecord::Relation)
|
122
|
+
self
|
123
|
+
elsif self.is_a?(::ActiveRecord::Base)
|
124
|
+
self.all
|
125
|
+
else
|
126
|
+
self.scope
|
127
|
+
end
|
128
|
+
group_values = scope.group_values
|
120
129
|
unless group_values.empty?
|
121
130
|
# total_entries left to an auto-count, but the relation being
|
122
131
|
# paginated has a grouping. we need to do a special count, lest
|
123
132
|
# self.count give us a hash instead of the integer we expect.
|
124
|
-
if
|
125
|
-
options[:total_entries] = except(:group).select(group_values).uniq.count
|
133
|
+
if scope.having_values.empty? && group_values.length == 1 # multi-column distinct counts are broken right now (as of rails 4.2.5) :(
|
134
|
+
options[:total_entries] = except(:group, :select).select(group_values).uniq.count
|
126
135
|
else
|
127
136
|
options[:total_entries] = unscoped.from("(#{to_sql}) a").count
|
128
137
|
end
|
129
138
|
end
|
130
139
|
end
|
131
|
-
super(options).
|
140
|
+
super(options).to_a
|
132
141
|
end
|
133
142
|
end
|
134
143
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: folio-pagination
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jacob Fugal
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
117
|
version: '0'
|
118
118
|
requirements: []
|
119
119
|
rubyforge_project:
|
120
|
-
rubygems_version: 2.4.
|
120
|
+
rubygems_version: 2.4.7
|
121
121
|
signing_key:
|
122
122
|
specification_version: 4
|
123
123
|
summary: Folio is a library for pagination. It's meant to be nearly compatible with
|