Skip to content

Commit 5dd21fa

Browse files
committed
rubocop appeasement
1 parent f93cb4e commit 5dd21fa

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

lib/mongoid/errors/unsupported_isolation_level.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
module Mongoid
44
module Errors
5-
65
# Raised when an unsupported isolation level is used in Mongoid
76
# configuration.
87
class UnsupportedIsolationLevel < MongoidError
@@ -13,7 +12,7 @@ class UnsupportedIsolationLevel < MongoidError
1312
def initialize(level)
1413
super(
1514
compose_message(
16-
"unsupported_isolation_level",
15+
'unsupported_isolation_level',
1716
{ level: level }
1817
)
1918
)

lib/mongoid/threaded.rb

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -515,21 +515,25 @@ def unset_current_scope(klass)
515515
delete(CURRENT_SCOPE_KEY) if scope.empty?
516516
end
517517

518-
# Returns the current thread- or fiber-local storage as a Hash.
518+
# Returns the current thread- or fiber-local storage as a Hash.
519519
def storage
520520
case Config.isolation_level
521521
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)
524527
end
525528

526-
Thread.current.thread_variable_get(STORAGE_KEY)
529+
storage_hash
530+
527531
when :fiber
528532
Fiber[STORAGE_KEY] ||= {}
533+
529534
else
530535
raise "Unknown isolation level: #{Config.isolation_level.inspect}"
531536
end
532537
end
533-
534538
end
535539
end

0 commit comments

Comments
 (0)