diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-07-02 17:19:21 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-07-02 17:19:21 -0700 |
commit | 6aea51355ae221a422e8501b585619895cded8f4 (patch) | |
tree | d4546cfc91d5d08f170efcb4774ca5d1b0501b95 /activerecord/lib/active_record/attribute_methods.rb | |
parent | 8eb7561ac6e8f020ec09608532de310c6b0b8dcd (diff) | |
download | rails-6aea51355ae221a422e8501b585619895cded8f4.tar.gz rails-6aea51355ae221a422e8501b585619895cded8f4.tar.bz2 rails-6aea51355ae221a422e8501b585619895cded8f4.zip |
eagerly assign the attribute name cache, remove const_missing
Diffstat (limited to 'activerecord/lib/active_record/attribute_methods.rb')
-rw-r--r-- | activerecord/lib/active_record/attribute_methods.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb index 701fd4e3fa..9f8f309c02 100644 --- a/activerecord/lib/active_record/attribute_methods.rb +++ b/activerecord/lib/active_record/attribute_methods.rb @@ -30,8 +30,11 @@ module ActiveRecord extend Mutex_m const_set :AttrNames, Module.new { - def self.const_missing(name) - const_set(name, [name.to_s.sub(/ATTR_/, '')].pack('h*').freeze) + def self.set_name_cache(name, value) + const_name = "ATTR_#{name}" + unless const_defined? const_name + const_set const_name, value + end end } } |