From 9f76531c3a7a6ff32515d2238cf26dbd772467d7 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 2 Jul 2013 17:03:32 -0700 Subject: push attribute constant cache in to the attribute methods module --- activerecord/lib/active_record/attribute_methods.rb | 10 +++++++++- activerecord/lib/active_record/core.rb | 6 ------ 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb index 5e990955ab..abaa820ac5 100644 --- a/activerecord/lib/active_record/attribute_methods.rb +++ b/activerecord/lib/active_record/attribute_methods.rb @@ -26,7 +26,15 @@ module ActiveRecord end def initialize_generated_modules # :nodoc: - @generated_attribute_methods = Module.new { extend Mutex_m } + @generated_attribute_methods = Module.new { + extend Mutex_m + + const_set :AttrNames, Module.new { + def self.const_missing(name) + const_set(name, [name.to_s.sub(/ATTR_/, '')].pack('h*').freeze) + end + } + } @attribute_methods_generated = false include @generated_attribute_methods end diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb index 7da70cea18..c6b7da2e3c 100644 --- a/activerecord/lib/active_record/core.rb +++ b/activerecord/lib/active_record/core.rb @@ -90,12 +90,6 @@ module ActiveRecord module ClassMethods def initialize_generated_modules super - # force attribute methods to be higher in inheritance hierarchy than other generated methods - generated_attribute_methods.const_set(:AttrNames, Module.new { - def self.const_missing(name) - const_set(name, [name.to_s.sub(/ATTR_/, '')].pack('h*').freeze) - end - }) generated_feature_methods end -- cgit v1.2.3