pagy 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 388922f4fd6c86c42945097ef08078bfe351e8b61a380ef68c58c583509ee4ae
4
- data.tar.gz: 775b71455d808039150ac6285a15c8fd9574609df2a43399f465d71fed853cff
3
+ metadata.gz: 404671150cf9cb3580df7ec51a52715dbec0ea879140f16b0f41d67714a9760e
4
+ data.tar.gz: 9074cfed85d9465b2484222b6063e3b282e4c910fc01388bd5155ce4348181e3
5
5
  SHA512:
6
- metadata.gz: a98e301538f52ebd068f137ff5bf7850ab713a28e8636b399753b8a70022d076885e3ac93216c7da255fb3d4269f8bd3c48990243e27db31ccc08f841af750b2
7
- data.tar.gz: d22e17a6910d0e1dbc31f184a69a9dae63a25932c7d29d2f9dc1d291d9ed5fe58c641bba96ae9feea2e312cd06e478643705688916d8b26c3395937a7fe0442c
6
+ metadata.gz: bbba1646133377c9dc118fdb184d694dd5b137d780cdd55009f61b7190f276e737e46cf0dd0ebd63957b4f8fb7a67cbc1ed409c0ac3a0055ab6a58db0eadece6
7
+ data.tar.gz: e7ef0461dc55852c9f6d1baa594cb495256d7cefdd6a230c36b139fcf9adfc16684d4e9b3e65a075c93891a2f315912c1e3f33e3c6bef5d909aa5f21f77e7303
@@ -3,7 +3,7 @@
3
3
 
4
4
  require 'pathname'
5
5
 
6
- class Pagy ; VERSION = '1.2.0'
6
+ class Pagy ; VERSION = '1.2.1'
7
7
 
8
8
  class OverflowError < StandardError; attr_reader :pagy; def initialize(pagy) @pagy = pagy end; end
9
9
 
@@ -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) # work with AR collections: other ORMs may need to change this
20
- count = count.count if count.is_a?(Hash) # fix for the AR grouping count inconsistency (Hash instead of Integer)
21
- # Return the merged variables to initialize the Pagy object
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
@@ -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
- # Return the merged variables to initialize the Pagy object
15
- { count: array.count,
16
- page: params[vars[:page_param]||VARS[:page_param]] }.merge!(vars)
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
- # Return the merged variables to initialize the Pagy object
21
- { page: params[vars[:page_param]||VARS[:page_param]] }.merge!(vars)
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
- # Return the merged variables to initialize the Pagy object
14
- { count: results.total,
15
- page: (params[:page] || 1)}.merge!(vars)
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
- # Return the merged variables to initialize the Pagy object
14
- { count: results.total_count,
15
- page: results.options[:page],
16
- items: results.options[:per_page] }.merge!(vars)
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.0
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-03 00:00:00.000000000 Z
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,