aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/attribute_methods
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-04-15 01:44:27 +0100
committerJon Leighton <j@jonathanleighton.com>2011-04-15 01:44:27 +0100
commitbbe0a507f287c20ab4ae8a244fbfc810665deda5 (patch)
tree028c75870bd593b3c3ae5fe8ead29e2a315a4937 /activerecord/lib/active_record/attribute_methods
parent3d44e4575825b30dc2407e3c421af23369224a34 (diff)
downloadrails-bbe0a507f287c20ab4ae8a244fbfc810665deda5.tar.gz
rails-bbe0a507f287c20ab4ae8a244fbfc810665deda5.tar.bz2
rails-bbe0a507f287c20ab4ae8a244fbfc810665deda5.zip
Remove unnecessary code from define_read_method and add assertion to make sure the underscored version is actually generated
Diffstat (limited to 'activerecord/lib/active_record/attribute_methods')
-rw-r--r--activerecord/lib/active_record/attribute_methods/read.rb11
1 files changed, 4 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/read.rb b/activerecord/lib/active_record/attribute_methods/read.rb
index 43f736c89c..dd3f4699f7 100644
--- a/activerecord/lib/active_record/attribute_methods/read.rb
+++ b/activerecord/lib/active_record/attribute_methods/read.rb
@@ -70,13 +70,10 @@ module ActiveRecord
if cache_attribute?(attr_name)
access_code = "@attributes_cache['#{attr_name}'] ||= (#{access_code})"
end
- if symbol =~ /^[a-zA-Z_]\w*[!?=]?$/
- generated_attribute_methods.module_eval("def _#{symbol}; #{access_code}; end; alias #{symbol} _#{symbol}", __FILE__, __LINE__)
- else
- generated_attribute_methods.module_eval do
- define_method("_#{symbol}") { eval(access_code) }
- alias_method(symbol, "_#{symbol}")
- end
+
+ generated_attribute_methods.module_eval do
+ define_method("_#{attr_name}") { eval(access_code) }
+ alias_method(attr_name, "_#{attr_name}")
end
end
end