pagy 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pagy.rb +1 -1
- data/lib/pagy/backend.rb +3 -4
- data/lib/pagy/extras/array.rb +4 -3
- data/lib/pagy/extras/countless.rb +2 -2
- data/lib/pagy/extras/elasticsearch_rails.rb +4 -3
- data/lib/pagy/extras/searchkick.rb +5 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 404671150cf9cb3580df7ec51a52715dbec0ea879140f16b0f41d67714a9760e
|
4
|
+
data.tar.gz: 9074cfed85d9465b2484222b6063e3b282e4c910fc01388bd5155ce4348181e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bbba1646133377c9dc118fdb184d694dd5b137d780cdd55009f61b7190f276e737e46cf0dd0ebd63957b4f8fb7a67cbc1ed409c0ac3a0055ab6a58db0eadece6
|
7
|
+
data.tar.gz: e7ef0461dc55852c9f6d1baa594cb495256d7cefdd6a230c36b139fcf9adfc16684d4e9b3e65a075c93891a2f315912c1e3f33e3c6bef5d909aa5f21f77e7303
|
data/lib/pagy.rb
CHANGED
data/lib/pagy/backend.rb
CHANGED
@@ -16,10 +16,9 @@ class Pagy
|
|
16
16
|
|
17
17
|
# Sub-method called only by #pagy: here for easy customization of variables by overriding
|
18
18
|
def pagy_get_vars(collection, vars)
|
19
|
-
count = collection.count(:all)
|
20
|
-
|
21
|
-
|
22
|
-
{ count: count, page: params[vars[:page_param]||VARS[:page_param]] }.merge!(vars)
|
19
|
+
vars[:count] ||= (c = collection.count(:all)).is_a?(Hash) ? c.size : c
|
20
|
+
vars[:page] ||= params[ vars[:page_param] || VARS[:page_param] ]
|
21
|
+
vars
|
23
22
|
end
|
24
23
|
|
25
24
|
# Sub-method called only by #pagy: here for easy customization of record-extraction by overriding
|
data/lib/pagy/extras/array.rb
CHANGED
@@ -10,10 +10,11 @@ class Pagy
|
|
10
10
|
return pagy, array[pagy.offset, pagy.items]
|
11
11
|
end
|
12
12
|
|
13
|
+
# Sub-method called only by #pagy_array: here for easy customization of variables by overriding
|
13
14
|
def pagy_array_get_vars(array, vars)
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
vars[:count] ||= array.size
|
16
|
+
vars[:page] ||= params[ vars[:page_param] || VARS[:page_param] ]
|
17
|
+
vars
|
17
18
|
end
|
18
19
|
|
19
20
|
end
|
@@ -17,8 +17,8 @@ class Pagy
|
|
17
17
|
|
18
18
|
# Sub-method called only by #pagy_countless: here for easy customization of variables by overriding
|
19
19
|
def pagy_countless_get_vars(_collection, vars)
|
20
|
-
|
21
|
-
|
20
|
+
vars[:page] ||= params[ vars[:page_param] || VARS[:page_param] ]
|
21
|
+
vars
|
22
22
|
end
|
23
23
|
|
24
24
|
# Sub-method called only by #pagy_countless: here for easy customization of record-extraction by overriding
|
@@ -9,10 +9,11 @@ class Pagy
|
|
9
9
|
return pagy, results.offset(pagy.offset).limit(pagy.items)
|
10
10
|
end
|
11
11
|
|
12
|
+
# Sub-method called only by #pagy_elasticsearch_rails: here for easy customization of variables by overriding
|
12
13
|
def pagy_elasticsearch_rails_get_vars(results, vars)
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
vars[:count] ||= results.total
|
15
|
+
vars[:page] ||= params[:page] || 1
|
16
|
+
vars
|
16
17
|
end
|
17
18
|
end
|
18
19
|
end
|
@@ -9,11 +9,12 @@ class Pagy
|
|
9
9
|
return pagy, results
|
10
10
|
end
|
11
11
|
|
12
|
+
# Sub-method called only by #pagy_searchkick: here for easy customization of variables by overriding
|
12
13
|
def pagy_searchkick_get_vars(results, vars)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
vars[:count] ||= results.total_count
|
15
|
+
vars[:page] ||= results.options[:page]
|
16
|
+
vars[:items] ||= results.options[:per_page]
|
17
|
+
vars
|
17
18
|
end
|
18
19
|
end
|
19
20
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pagy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Domizio Demichelis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-12-
|
11
|
+
date: 2018-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: 'Agnostic pagination in plain ruby: it works with any framework, ORM
|
14
14
|
and DB type, with all kinds of collections, even pre-paginated, scopes, Arrays,
|