bullet_train-super_load_and_authorize_resource 1.5.1 → 1.5.2
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: c846504e5afa68992db9ba4cf57f26c7018390faaab897ce586b4483194ffda7
|
4
|
+
data.tar.gz: '04529abe424c941fd5ce403ca31e183e36b6212ad1c9c6a80eed6fb4c33aae89'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d29fa41b1dd5bc63d76ac7245af221ede9cee7a922d2f7be30edd59754522263eed8801c92d3a6fceee61e15ab61ecc91c0832b27e70559b1571d3187a74399
|
7
|
+
data.tar.gz: 863e9a588b817b0c8efd6c56967aa5c4741c65cbdb1755668d86752acb486e1deaee87109d8182956af610ad2b4d071027b2701064965a057ed29df71e94f20f
|
@@ -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.5.
|
4
|
+
version: 1.5.2
|
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-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cancancan
|