From 09b31f08d4a4930dc66d401c94b2e5e49c250fc1 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 2 Jul 2013 14:34:03 -0700 Subject: eagerly initialize the attributes module to avoid check-then-set race conditions --- activemodel/lib/active_model/attribute_methods.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'activemodel/lib') 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 -- cgit v1.2.3