Permalink
Browse files

Put mutex at class level

  • Loading branch information...
durran committed Nov 14, 2012
1 parent 4f74ce6 commit 6f54b85d759b0d57392e5cf35ea5b63587d32562
Showing with 3 additions and 18 deletions.
  1. +3 −18 lib/mongoid/config.rb
View
@@ -13,6 +13,8 @@ module Config
extend Options
include ActiveModel::Observing
+ LOCK = Mutex.new
+
option :allow_dynamic_fields, default: true
option :identity_map_enabled, default: false
option :include_root_in_json, default: false
@@ -108,7 +110,7 @@ def models
#
# @since 3.1.0
def register_model(klass)
- lock.synchronize do
+ LOCK.synchronize do
models.push(klass) unless models.include?(klass)
end
end
@@ -255,22 +257,5 @@ def time_zone
def running_with_passenger?
@running_with_passenger ||= defined?(PhusionPassenger)
end
-
- private
-
- # Gets the mutex for synchronizing methods on the configuration.
- #
- # @api private
- #
- # @example Get the mutex.
- # config.lock
- #
- # @return [ Mutex ] The mutex.
- #
- # @since 3.1.0
- def lock
- @mutex ||= Mutex.new
- end
-
end
end

0 comments on commit 6f54b85

Please sign in to comment.