cancancan 3.6.0 → 3.6.2
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f110f791b83ea1cc157fae66dd576a3dae94f60b983d654e8be252cb6c4e8939
|
|
4
|
+
data.tar.gz: cbf9e6c8e6fadca715eeff37cfce3b289550d538e84a5996b4e95aa00632d7fd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8102b54914e87e65dbd15b27991e33462d5083d37c6f57aaf09a2dfeaff92826420e27863bd88e17a8c1f18939281ec36ed2abb70e2e012df16661997af5f98a
|
|
7
|
+
data.tar.gz: 6b1defbddb0262274e8ad349fb6b267fa45b4024ca790ba3ba93f67d741cc38055e37e485d57f7ff17b59244a5c235d42e956b9049b603d2d8aa28898a4dd768
|
|
@@ -31,7 +31,7 @@ module CanCan
|
|
|
31
31
|
klass = subject_class?(subject) ? subject : subject.class
|
|
32
32
|
# empty attributes is an 'all'
|
|
33
33
|
if rule.attributes.empty? && klass < ActiveRecord::Base
|
|
34
|
-
klass.
|
|
34
|
+
klass.attribute_names.map(&:to_sym) - Array(klass.primary_key)
|
|
35
35
|
else
|
|
36
36
|
rule.attributes
|
|
37
37
|
end
|
|
@@ -171,6 +171,11 @@ module CanCan
|
|
|
171
171
|
# [:+instance_name+]
|
|
172
172
|
# The name of the instance variable for this resource.
|
|
173
173
|
#
|
|
174
|
+
# [:+id_param+]
|
|
175
|
+
# Find using a param key other than :id. For example:
|
|
176
|
+
#
|
|
177
|
+
# load_resource :id_param => :url # will use find(params[:url])
|
|
178
|
+
#
|
|
174
179
|
# [:+through+]
|
|
175
180
|
# Authorize conditions on this parent resource when instance isn't available.
|
|
176
181
|
#
|
|
@@ -208,7 +213,7 @@ module CanCan
|
|
|
208
213
|
def skip_load_resource(*args)
|
|
209
214
|
options = args.extract_options!
|
|
210
215
|
name = args.first
|
|
211
|
-
|
|
216
|
+
add_cancan_skip(:load, name, options)
|
|
212
217
|
end
|
|
213
218
|
|
|
214
219
|
# Skip the authorization behavior of CanCan. This is useful when using +load_and_authorize_resource+ but want to
|
|
@@ -224,7 +229,7 @@ module CanCan
|
|
|
224
229
|
def skip_authorize_resource(*args)
|
|
225
230
|
options = args.extract_options!
|
|
226
231
|
name = args.first
|
|
227
|
-
|
|
232
|
+
add_cancan_skip(:authorize, name, options)
|
|
228
233
|
end
|
|
229
234
|
|
|
230
235
|
# Add this to a controller to ensure it performs authorization through +authorize+! or +authorize_resource+ call.
|
|
@@ -290,6 +295,15 @@ module CanCan
|
|
|
290
295
|
def cancan_skipper
|
|
291
296
|
self._cancan_skipper ||= { authorize: {}, load: {} }
|
|
292
297
|
end
|
|
298
|
+
|
|
299
|
+
private
|
|
300
|
+
|
|
301
|
+
# _cancan_skipper is a class_attribute: a subclass shares the hash of its superclass until it assigns
|
|
302
|
+
# its own. Assign a copy, so a skip in a subclass does not change the superclass or sibling classes.
|
|
303
|
+
def add_cancan_skip(behavior, name, options)
|
|
304
|
+
skipper = cancan_skipper
|
|
305
|
+
self._cancan_skipper = skipper.merge(behavior => skipper[behavior].merge(name => options))
|
|
306
|
+
end
|
|
293
307
|
end
|
|
294
308
|
|
|
295
309
|
def self.included(base)
|
|
@@ -49,11 +49,22 @@ module CanCan
|
|
|
49
49
|
def visit_nodes(node)
|
|
50
50
|
# Rails 5.2 adds a BindParam node that prevents the visitor method from properly compiling the SQL query
|
|
51
51
|
if self.class.version_greater_or_equal?('5.2.0')
|
|
52
|
-
connection =
|
|
52
|
+
connection = model_connection
|
|
53
53
|
collector = Arel::Collectors::SubstituteBinds.new(connection, Arel::Collectors::SQLString.new)
|
|
54
54
|
connection.visitor.accept(node, collector).value
|
|
55
55
|
else
|
|
56
|
-
|
|
56
|
+
model_connection.visitor.compile(node)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Rails 7.2 soft-deprecated ActiveRecord::Base.connection in favour of
|
|
61
|
+
# lease_connection, which better describes its lifecycle. Fall back to
|
|
62
|
+
# connection for Rails < 7.2 where lease_connection is not defined.
|
|
63
|
+
def model_connection
|
|
64
|
+
if @model_class.respond_to?(:lease_connection)
|
|
65
|
+
@model_class.lease_connection
|
|
66
|
+
else
|
|
67
|
+
@model_class.send(:connection)
|
|
57
68
|
end
|
|
58
69
|
end
|
|
59
70
|
end
|
data/lib/cancan/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cancancan
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.6.
|
|
4
|
+
version: 3.6.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alessandro Rodi (Renuo AG)
|
|
8
8
|
- Bryan Rite
|
|
9
9
|
- Ryan Bates
|
|
10
10
|
- Richard Wilson
|
|
11
|
-
autorequire:
|
|
12
11
|
bindir: bin
|
|
13
12
|
cert_chain: []
|
|
14
|
-
date:
|
|
13
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
15
14
|
dependencies:
|
|
16
15
|
- !ruby/object:Gem::Dependency
|
|
17
16
|
name: appraisal
|
|
@@ -157,7 +156,6 @@ licenses:
|
|
|
157
156
|
- MIT
|
|
158
157
|
metadata:
|
|
159
158
|
funding_uri: https://github.com/sponsors/coorasse
|
|
160
|
-
post_install_message:
|
|
161
159
|
rdoc_options: []
|
|
162
160
|
require_paths:
|
|
163
161
|
- lib
|
|
@@ -172,8 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
172
170
|
- !ruby/object:Gem::Version
|
|
173
171
|
version: '0'
|
|
174
172
|
requirements: []
|
|
175
|
-
rubygems_version: 3.
|
|
176
|
-
signing_key:
|
|
173
|
+
rubygems_version: 3.6.9
|
|
177
174
|
specification_version: 4
|
|
178
175
|
summary: Simple authorization solution for Rails.
|
|
179
176
|
test_files: []
|