File tree Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change 2
2
3
3
module Mongoid
4
4
module Errors
5
-
6
5
# Raised when an unsupported isolation level is used in Mongoid
7
6
# configuration.
8
7
class UnsupportedIsolationLevel < MongoidError
@@ -13,7 +12,7 @@ class UnsupportedIsolationLevel < MongoidError
13
12
def initialize ( level )
14
13
super (
15
14
compose_message (
16
- " unsupported_isolation_level" ,
15
+ ' unsupported_isolation_level' ,
17
16
{ level : level }
18
17
)
19
18
)
Original file line number Diff line number Diff line change @@ -515,21 +515,25 @@ def unset_current_scope(klass)
515
515
delete ( CURRENT_SCOPE_KEY ) if scope . empty?
516
516
end
517
517
518
- # Returns the current thread- or fiber-local storage as a Hash.
518
+ # Returns the current thread- or fiber-local storage as a Hash.
519
519
def storage
520
520
case Config . isolation_level
521
521
when :thread
522
- if !Thread . current . thread_variable? ( STORAGE_KEY )
523
- Thread . current . thread_variable_set ( STORAGE_KEY , { } )
522
+ storage_hash = Thread . current . thread_variable_get ( STORAGE_KEY )
523
+
524
+ unless storage_hash
525
+ storage_hash = { }
526
+ Thread . current . thread_variable_set ( STORAGE_KEY , storage_hash )
524
527
end
525
528
526
- Thread . current . thread_variable_get ( STORAGE_KEY )
529
+ storage_hash
530
+
527
531
when :fiber
528
532
Fiber [ STORAGE_KEY ] ||= { }
533
+
529
534
else
530
535
raise "Unknown isolation level: #{ Config . isolation_level . inspect } "
531
536
end
532
537
end
533
-
534
538
end
535
539
end
You can’t perform that action at this time.
0 commit comments