bullet_train-super_load_and_authorize_resource 1.5.1 → 1.6.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55b8c178e08ec31fa070c7050997504e62ad3fe5a3144ab48aaabc22a024bbb6
|
4
|
+
data.tar.gz: b26bec97cc2bdfd035ad54556ad86fb5dc11e09fd9703065cdc849376b29980d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20eaceb1d47a3f75a9c38902ba57977c7ea346eecfb6299f3a8394da440f353ed7eea32cee600c8c97d8c3d896a5ed0e09c9de188a16e220088b7fba1eded562
|
7
|
+
data.tar.gz: 76361205a48f962b66066a531452509b562979c8f1043c37d2c9e7a42d0a5fce085a31c95f4fc66b5f9116fda9b1c8d2b53d70b3767ec9746c258c4e54c9ae8a
|
@@ -2,17 +2,18 @@ module BulletTrain::LoadsAndAuthorizesResource
|
|
2
2
|
extend ActiveSupport::Concern
|
3
3
|
|
4
4
|
class_methods do
|
5
|
+
# Returns an array of module names based on the classes namespace minus regex_to_remove_controller_namespace
|
5
6
|
def model_namespace_from_controller_namespace
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
7
|
+
name
|
8
|
+
.gsub(regex_to_remove_controller_namespace || //, "")
|
9
|
+
.split("::")
|
10
|
+
.tap(&:pop) # drops actual class name
|
11
|
+
end
|
12
|
+
|
13
|
+
def regex_to_remove_controller_namespace
|
14
|
+
return super if defined?(super)
|
15
|
+
|
16
|
+
raise "This is a template method that needs to be implemented by controllers including LoadsAndAuthorizesResource."
|
16
17
|
end
|
17
18
|
|
18
19
|
# this is one of the few pieces of 'magical' functionality that bullet train implements
|
@@ -202,22 +203,14 @@ module BulletTrain::LoadsAndAuthorizesResource
|
|
202
203
|
end
|
203
204
|
end
|
204
205
|
|
205
|
-
def regex_to_remove_controller_namespace
|
206
|
-
raise "This is a template method that needs to be implemented by controllers including LoadsAndAuthorizesResource."
|
207
|
-
end
|
208
|
-
|
209
206
|
def load_team
|
210
|
-
|
211
|
-
# so we give @team a nil value if no association is found.
|
212
|
-
begin
|
213
|
-
# Sometimes `@team` has already been populated by earlier `before_action` steps.
|
214
|
-
@team ||= @child_object&.team || @parent_object&.team
|
215
|
-
rescue NoMethodError
|
216
|
-
@team = nil
|
217
|
-
end
|
207
|
+
@team ||= @child_object&.try(:team) || @parent_object&.try(:team)
|
218
208
|
|
219
|
-
|
220
|
-
|
209
|
+
return unless @team
|
210
|
+
|
211
|
+
if defined?(Current) && Current.respond_to?(:team=)
|
212
|
+
Current.team = @team
|
213
|
+
end
|
221
214
|
|
222
215
|
# If the currently loaded team is saved to the database, make that the user's new current team.
|
223
216
|
if @team.try(:persisted?)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bullet_train-super_load_and_authorize_resource
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Culver
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-10-
|
11
|
+
date: 2023-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cancancan
|