cancancan 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/cancancan.gemspec +1 -1
- data/lib/cancan/ability.rb +5 -6
- data/lib/cancan/controller_additions.rb +7 -5
- data/lib/cancan/controller_resource.rb +5 -2
- data/lib/cancan/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9115e4337e5f3acf25ada77c66a9e2eef4627cd8
|
4
|
+
data.tar.gz: 530b77ec0c2f974624e814a65d798864b30324b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e4091db3eb5acc0567e7d9c80df489974013021a5ee54010a4f9406727680d753c48d955b31e4285fb6903aedfda66089f9a12c2afc07e9e55b90545f31de69
|
7
|
+
data.tar.gz: 438619dd7cde250eb3598ed34cdc28f514a7d9ce2fa18221cdc3c945312a855ab5cb3c378e5c7737367551353f39f2fdf4e37fd16371e4af3d18b88eb9985da3
|
data/cancancan.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.required_ruby_version = '>= 2.0.0'
|
22
22
|
|
23
23
|
s.add_development_dependency 'bundler', '~> 1.3'
|
24
|
-
s.add_development_dependency 'rubocop', '~> 0.
|
24
|
+
s.add_development_dependency 'rubocop', '~> 0.48.1'
|
25
25
|
s.add_development_dependency 'rake', '~> 10.1', '>= 10.1.1'
|
26
26
|
s.add_development_dependency 'rspec', '~> 3.2', '>= 3.2.0'
|
27
27
|
s.add_development_dependency 'appraisal', '~> 2.0', '>= 2.0.0'
|
data/lib/cancan/ability.rb
CHANGED
@@ -223,7 +223,7 @@ module CanCan
|
|
223
223
|
keys = unauthorized_message_keys(action, subject)
|
224
224
|
variables = { action: action.to_s }
|
225
225
|
variables[:subject] = (subject.class == Class ? subject : subject.class).to_s.underscore.humanize.downcase
|
226
|
-
message = I18n.translate(
|
226
|
+
message = I18n.translate(keys.shift, variables.merge(scope: :unauthorized, default: keys + ['']))
|
227
227
|
message.blank? ? nil : message
|
228
228
|
end
|
229
229
|
|
@@ -291,11 +291,10 @@ module CanCan
|
|
291
291
|
|
292
292
|
def unauthorized_message_keys(action, subject)
|
293
293
|
subject = (subject.class == Class ? subject : subject.class).name.underscore unless subject.is_a? Symbol
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
end.flatten
|
294
|
+
aliases = aliases_for_action(action)
|
295
|
+
[subject, :all].product([*aliases, :manage]).map do |try_subject, try_action|
|
296
|
+
:"#{try_action}.#{try_subject}"
|
297
|
+
end
|
299
298
|
end
|
300
299
|
|
301
300
|
# Accepts an array of actions and returns an array of actions which match.
|
@@ -40,7 +40,7 @@ module CanCan
|
|
40
40
|
# private
|
41
41
|
#
|
42
42
|
# def find_book_by_permalink
|
43
|
-
# @book = Book.find_by_permalink!(params[:id)
|
43
|
+
# @book = Book.find_by_permalink!(params[:id])
|
44
44
|
# end
|
45
45
|
# end
|
46
46
|
#
|
@@ -285,13 +285,14 @@ module CanCan
|
|
285
285
|
end
|
286
286
|
|
287
287
|
def cancan_skipper
|
288
|
-
|
288
|
+
self._cancan_skipper ||= { authorize: {}, load: {} }
|
289
289
|
end
|
290
290
|
end
|
291
291
|
|
292
292
|
def self.included(base)
|
293
293
|
base.extend ClassMethods
|
294
294
|
base.helper_method :can?, :cannot?, :current_ability if base.respond_to? :helper_method
|
295
|
+
base.class_attribute :_cancan_skipper
|
295
296
|
end
|
296
297
|
|
297
298
|
# Raises a CanCan::AccessDenied exception if the current_ability cannot
|
@@ -383,8 +384,9 @@ module CanCan
|
|
383
384
|
end
|
384
385
|
end
|
385
386
|
|
386
|
-
if defined? ActionController
|
387
|
-
|
388
|
-
|
387
|
+
if defined? ActionController
|
388
|
+
%w[Base API].each do |klass|
|
389
|
+
next unless ActionController.const_defined?(klass)
|
390
|
+
ActionController.const_get(klass).class_eval { include CanCan::ControllerAdditions }
|
389
391
|
end
|
390
392
|
end
|
@@ -170,7 +170,8 @@ module CanCan
|
|
170
170
|
end
|
171
171
|
|
172
172
|
def resource_instance
|
173
|
-
@controller.
|
173
|
+
return unless load_instance? && @controller.instance_variable_defined?("@#{instance_name}")
|
174
|
+
@controller.instance_variable_get("@#{instance_name}")
|
174
175
|
end
|
175
176
|
|
176
177
|
def collection_instance=(instance)
|
@@ -178,6 +179,7 @@ module CanCan
|
|
178
179
|
end
|
179
180
|
|
180
181
|
def collection_instance
|
182
|
+
return unless @controller.instance_variable_defined?("@#{instance_name.to_s.pluralize}")
|
181
183
|
@controller.instance_variable_get("@#{instance_name.to_s.pluralize}")
|
182
184
|
end
|
183
185
|
|
@@ -258,7 +260,8 @@ module CanCan
|
|
258
260
|
elsif @options[:class] && @params.key?(extract_key(@options[:class]))
|
259
261
|
@params[extract_key(@options[:class])]
|
260
262
|
else
|
261
|
-
@params[extract_key(namespaced_name)]
|
263
|
+
params = @params[extract_key(namespaced_name)]
|
264
|
+
params.is_a?(Hash) ? params : nil
|
262
265
|
end
|
263
266
|
end
|
264
267
|
|
data/lib/cancan/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cancancan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alessandro Rodi (Renuo AG)
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2017-
|
14
|
+
date: 2017-11-10 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|
@@ -33,14 +33,14 @@ dependencies:
|
|
33
33
|
requirements:
|
34
34
|
- - "~>"
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version:
|
36
|
+
version: 0.48.1
|
37
37
|
type: :development
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
41
|
- - "~>"
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
43
|
+
version: 0.48.1
|
44
44
|
- !ruby/object:Gem::Dependency
|
45
45
|
name: rake
|
46
46
|
requirement: !ruby/object:Gem::Requirement
|
@@ -147,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
147
147
|
version: '0'
|
148
148
|
requirements: []
|
149
149
|
rubyforge_project:
|
150
|
-
rubygems_version: 2.
|
150
|
+
rubygems_version: 2.6.13
|
151
151
|
signing_key:
|
152
152
|
specification_version: 4
|
153
153
|
summary: Simple authorization solution for Rails.
|