rao-resources_controller 0.0.22.pre → 0.0.23.pre

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 809a6b4b2493009c0e2cf5d3a120c6bd4e1afd8f2139af0e61f44125d57cf28a
4
- data.tar.gz: 80504d7afed80dde55addda08776731a2e55293f4991c246ec9e28aa3290d901
3
+ metadata.gz: 412f93abb3a7cbe7ac330669de53922a68af511670f948d04e9f31c6e9ff2570
4
+ data.tar.gz: d4f22d1f199829d1ade3a72493743a6d00a48025c0ac9b6dcc5e7638a5f54b17
5
5
  SHA512:
6
- metadata.gz: 2a4c5a31b95c384ce4e9205c382e939a7f71b82117bb7c8ae567de1244defafa4323f94b8db54f486b51c28f8e2d2916f8532387ab6480ebae55fef4d7fa8511
7
- data.tar.gz: 736a7c62941b1da53def3c5e749c711ebf046a625d6d1fe6eab322c452f9630952b8e7f53164a9ddaae3a219efd39c024d2d6393377da786711a513f840dcec0
6
+ metadata.gz: 80593943db9b36a0e1d2455bb83cab1f74c7aa0360f2d99bd4c54416fdca5bd0888c7e17e9bd683b63a38f7654d7c0b9671612e281a958539dabc910de7e0ed3
7
+ data.tar.gz: d6016ff1546ba449c51b5b375d760ac43ba569ff2d3cc06ef0117d6e97bd956851af6fc506e09308b54a667730360047e8dbe7c67206bc8fc6c341be0b5b441b
@@ -17,10 +17,18 @@ module Rao
17
17
  end
18
18
 
19
19
  def per_page
20
- if [nil, 'all'].include?(params[:per_page])
21
- load_collection_scope.count
20
+ # Return page size from configuration if per_page is not present in params
21
+ unless params.has_key?(:per_page)
22
+ return Rao::ResourcesController::Configuration.pagination_per_page_default
23
+ end
24
+
25
+ # Return count of all records or nil if no records present if
26
+ # params[:per_page] equals 'all'. Otherwise return params[:per_page]
27
+ if params[:per_page] == 'all'
28
+ count = load_collection_scope.count
29
+ count > 0 ? count : nil
22
30
  else
23
- Rao::ResourcesController::Configuration.pagination_per_page_default
31
+ params[:per_page]
24
32
  end
25
33
  end
26
34
  end
@@ -19,11 +19,19 @@ module Rao
19
19
  end
20
20
 
21
21
  def per_page
22
- if [nil, 'all'].include?(params[:per_page])
23
- load_collection_scope.count
24
- else
22
+ # Return page size from configuration if per_page is not present in params
23
+ unless params.has_key?(:per_page)
25
24
  Rao::ResourcesController::Configuration.pagination_per_page_default
26
25
  end
26
+
27
+ # Return count of all records or nil if no records present if
28
+ # params[:per_page] equals 'all'. Otherwise return params[:per_page]
29
+ if params[:per_page] == 'all'
30
+ count = load_collection_scope.count
31
+ count > 0 ? count : nil
32
+ else
33
+ params[:per_page]
34
+ end
27
35
  end
28
36
  end
29
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rao-resources_controller
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.22.pre
4
+ version: 0.0.23.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roberto Vasquez Angel