rao-resources_controller 0.0.20.pre → 0.0.21.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: d8b24e64f50651b8f40503a327de474ae205eecd5dde8022023b4d0444f3572a
4
- data.tar.gz: c038ab4f63071bbce826fdbcf74e5dc66d387c63e250c84159dc6ed241d7787e
3
+ metadata.gz: 4fff12e71b5abd4c04de6759e3ca9d0ce5784ae2388b57729ffa1a4c356f075c
4
+ data.tar.gz: d0a06e05b176b0f90ad9ed86fdf0532c7d48ad1e40e4622659bf3ac93b66ecac
5
5
  SHA512:
6
- metadata.gz: fffbb39a441f766179e1f6f8bd4ea08761d2883fb00fbb7b556ed0978dfc0e76a2ad0725b68cbdd7cb24de2838c0d5b348a82b0547b79f98a69e8506840e7d3e
7
- data.tar.gz: bee3484473909a8953ed7c14fb42966239551382d4982b34dc32cc10146e62587c1fe673d23b54be56c802e631b40095abed01206b48eaadd49881034130c0bb
6
+ metadata.gz: 16995d2c6e3fda2857fbd91952121bde6cf9a1a41da5216df92935a3e93a8baebdd69b335f47d7358b1fcf6d04f66046263e992bb0fb63209706a680df41eb9f
7
+ data.tar.gz: 5d6a6dfc118a14b62e040d16d3767d72480fe01cda552cc68964399af26a915a186e085622745e17fbd4200ed4157fc34914ba5a6b8c333cda8178cfe9e84814
@@ -13,7 +13,15 @@ module Rao
13
13
  private
14
14
 
15
15
  def load_collection
16
- @collection = load_collection_scope.page(params[:page])
16
+ @collection = load_collection_scope.page(params[:page]).per(per_page)
17
+ end
18
+
19
+ def per_page
20
+ if [nil, 'all'].include?(params[:per_page])
21
+ nil
22
+ else
23
+ Rao::ResourcesController::Configuration.pagination_per_page_default
24
+ end
17
25
  end
18
26
  end
19
27
  end
@@ -1,16 +1,4 @@
1
1
  module Rao
2
- # Setting the pagination size in the controller:
3
- #
4
- # # app/controllers/posts_controller.rb
5
- # class PostsController < ApplicationController
6
- # # ...
7
- # private
8
- #
9
- # def per_page
10
- # 15
11
- # end
12
- # end
13
- #
14
2
  module ResourcesController::WillPaginateConcern
15
3
  extend ActiveSupport::Concern
16
4
 
@@ -26,8 +14,16 @@ module Rao
26
14
 
27
15
  def load_collection
28
16
  options = { page: params[:page] }
29
- options[:per_page] = per_page if respond_to?(:per_page, true)
17
+ options[:per_page] = per_page unless per_page.nil?
30
18
  @collection = load_collection_scope.paginate(options)
31
19
  end
20
+
21
+ def per_page
22
+ if [nil, 'all'].include?(params[:per_page])
23
+ nil
24
+ else
25
+ Rao::ResourcesController::Configuration.pagination_per_page_default
26
+ end
27
+ end
32
28
  end
33
29
  end
@@ -4,4 +4,12 @@ Rao::ResourcesController.configure do |config|
4
4
  # default: config.resources_controller_base_class_name = '::ApplicationController'
5
5
  #
6
6
  config.resources_controller_base_class_name = '::ApplicationController'
7
+
8
+ # Set the pagination item count per page.
9
+ #
10
+ # Works for kaminari and will_paginate.
11
+ #
12
+ # default: config.pagination_per_page_default = 25
13
+ #
14
+ config.pagination_per_page_default = 25
7
15
  end
@@ -6,6 +6,7 @@ module Rao
6
6
  end
7
7
 
8
8
  mattr_accessor(:resources_controller_base_class_name) { "::ApplicationController" }
9
+ mattr_accessor(:pagination_per_page_default) { 25 }
9
10
  end
10
11
  end
11
12
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rao-resources_controller
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.20.pre
4
+ version: 0.0.21.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roberto Vasquez Angel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-24 00:00:00.000000000 Z
11
+ date: 2019-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails