aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/base.rb
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2012-01-20 18:17:36 +0000
committerJon Leighton <j@jonathanleighton.com>2012-01-20 18:31:41 +0000
commitfab664a8e9c94d7e3c52fed70ea2c0f569d142fb (patch)
tree9f87d7210c4054531138dd270ab4328680a80b3c /activerecord/lib/active_record/base.rb
parentf36dcaf488b4357a52f43e3912628428956d351f (diff)
downloadrails-fab664a8e9c94d7e3c52fed70ea2c0f569d142fb.tar.gz
rails-fab664a8e9c94d7e3c52fed70ea2c0f569d142fb.tar.bz2
rails-fab664a8e9c94d7e3c52fed70ea2c0f569d142fb.zip
Fix another race condition.
From 2c667f69aa2daac5ee6c29ca9679616e2a71532a. Thanks @pwnall for the heads-up. Conflicts: activerecord/lib/active_record/core.rb
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rw-r--r--activerecord/lib/active_record/base.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index fa5846de39..198db715b2 100644
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -5,6 +5,7 @@ end
require 'yaml'
require 'set'
+require 'thread'
require 'active_support/benchmarkable'
require 'active_support/dependencies'
require 'active_support/descendants_tracker'
@@ -390,12 +391,18 @@ module ActiveRecord #:nodoc:
class << self # Class methods
def inherited(child_class) #:nodoc:
- # force attribute methods to be higher in inheritance hierarchy than other generated methods
- child_class.generated_attribute_methods
- child_class.generated_feature_methods
+ child_class.initialize_generated_modules
super
end
+ def initialize_generated_modules #:nodoc:
+ @attribute_methods_mutex = Mutex.new
+
+ # force attribute methods to be higher in inheritance hierarchy than other generated methods
+ generated_attribute_methods
+ generated_feature_methods
+ end
+
def generated_feature_methods
@generated_feature_methods ||= begin
mod = const_set(:GeneratedFeatureMethods, Module.new)