aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-07-02 14:34:03 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-07-02 14:34:40 -0700
commit09b31f08d4a4930dc66d401c94b2e5e49c250fc1 (patch)
treef76e83a5e1b031a298862859a31b2db1558a8e9d /activemodel
parent77f40cf9aa1a926e0b04db7c4f82471514f23d6c (diff)
downloadrails-09b31f08d4a4930dc66d401c94b2e5e49c250fc1.tar.gz
rails-09b31f08d4a4930dc66d401c94b2e5e49c250fc1.tar.bz2
rails-09b31f08d4a4930dc66d401c94b2e5e49c250fc1.zip
eagerly initialize the attributes module to avoid check-then-set race conditions
Diffstat (limited to 'activemodel')
-rw-r--r--activemodel/lib/active_model/attribute_methods.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/activemodel/lib/active_model/attribute_methods.rb b/activemodel/lib/active_model/attribute_methods.rb
index 1ba5b0e3d4..f336c759d2 100644
--- a/activemodel/lib/active_model/attribute_methods.rb
+++ b/activemodel/lib/active_model/attribute_methods.rb
@@ -1,4 +1,5 @@
require 'thread_safe'
+require 'mutex_m'
module ActiveModel
# Raised when an attribute is not defined.
@@ -333,7 +334,9 @@ module ActiveModel
end
def generated_attribute_methods #:nodoc:
- @generated_attribute_methods ||= Module.new.tap { |mod| include mod }
+ @generated_attribute_methods ||= Module.new {
+ extend Mutex_m
+ }.tap { |mod| include mod }
end
protected