cant_cant_cant 0.1.4 → 0.1.5

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
  SHA1:
3
- metadata.gz: 61a7efa9c825d8ce19d56c2b16698949af270f8e
4
- data.tar.gz: ea1c070a2b8ac114e3f77e27bbd332980784eeb0
3
+ metadata.gz: e8451255f09ffd6697833ad211440b2c77622f84
4
+ data.tar.gz: 7805695ac5b9231f48dc29e5fd4f00837705e682
5
5
  SHA512:
6
- metadata.gz: 12b5810cb51ab434973a13399b6511fb1e8881dc1d8e7e930c40b91e705e57ae6ea4f9aa436a84553cee48e8892edba9281ba1a7b560118406aa779141869292
7
- data.tar.gz: 871b0dab0b3ef161e106e6222ad80ae46cbdb8297a3e65984cc68241e91bdbc6bb7e2e3ec7772fa25d6e3ace94a86ef3443ecbd7513c3b8fe141d6792a7a6437
6
+ metadata.gz: 0afaf9d1223b2593b791610419d1a97689737bf8e3b97d8b7be2617814410c1be3a455cb49e775f4592d8bef3638d3ff11dac9b0c878a6851d638a92e261c4ee
7
+ data.tar.gz: 6df17d293abca350ed1bd1bc0c1d708f14fff90dfc864dd610bb9fba5a65217b88f44cc2027d4b6487318743ea750660e951b3ec570fcd223917e65fe3e747c5
@@ -42,19 +42,20 @@ module CantCantCant
42
42
  end
43
43
 
44
44
  def extract_controller(param)
45
- controller, action = param.split('#')
45
+ controller_param, action = param.split('#')
46
46
  raise if controller.blank? || action.blank?
47
47
 
48
- controller = (controller + '_controller').classify.constantize
48
+ const_name = "#{controller_param.classify}Controller"
49
+ controller_class = ActiveSupport::Dependencies.constantize(const_name)
49
50
 
50
- [controller, action]
51
+ [controller_class, action]
51
52
  rescue RuntimeError, NameError
52
53
  raise InvalidControllerOrAction, param
53
54
  end
54
55
 
55
56
  def inject_action(param)
56
- controller, action = extract_controller(param)
57
- controller.class_eval do
57
+ controller_class, action = extract_controller(param)
58
+ controller_class.class_eval do
58
59
  before_action(only: [action]) do
59
60
  next true if CantCantCant.allow?(param, current_roles)
60
61
  raise PermissionDenied, param
@@ -1,5 +1,7 @@
1
- config = File.join(Rails.root, 'config/cant_cant_cant.yml')
2
- CantCantCant.initialize(config)
1
+ Rails.application.config.after_initialize do
2
+ config = File.join(Rails.root, 'config/cant_cant_cant.yml')
3
+ CantCantCant.initialize(config)
4
+ end
3
5
 
4
6
  class ActionController::Base
5
7
  # Write your own handler
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cant_cant_cant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shou Ya
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-08 00:00:00.000000000 Z
11
+ date: 2016-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -59,7 +59,6 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
- - MIT-LICENSE
63
62
  - README.md
64
63
  - Rakefile
65
64
  - lib/cant_cant_cant.rb
data/MIT-LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright 2016 Shou Ya
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.