Permalink
Browse files

push attribute constant cache in to the attribute methods module

  • Loading branch information...
1 parent c107164 commit 4b896f998640a79b654b22c2ab93a490a2606b1f @tenderlove tenderlove committed Jul 3, 2013
Showing with 9 additions and 7 deletions.
  1. +9 −1 activerecord/lib/active_record/attribute_methods.rb
  2. +0 −6 activerecord/lib/active_record/core.rb
@@ -26,7 +26,15 @@ def inherited(child_class) #:nodoc:
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
@@ -93,12 +93,6 @@ def self.connection_handler=(handler)
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

0 comments on commit 4b896f9

Please sign in to comment.