diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-06-30 11:53:06 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-06-30 15:31:22 -0700 |
commit | f7bd07b62a9372f7b370dd6959dec39e92e77dfe (patch) | |
tree | 14116a79c79f561ff651704a1799361fea664f8a /activerecord | |
parent | f261ef42cc2c8f0fc31d6e6f464bacd6ca9eb581 (diff) | |
download | rails-f7bd07b62a9372f7b370dd6959dec39e92e77dfe.tar.gz rails-f7bd07b62a9372f7b370dd6959dec39e92e77dfe.tar.bz2 rails-f7bd07b62a9372f7b370dd6959dec39e92e77dfe.zip |
only calculate method name once
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/attribute_methods/read.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/read.rb b/activerecord/lib/active_record/attribute_methods/read.rb index 7d4182291a..9a50a20fbc 100644 --- a/activerecord/lib/active_record/attribute_methods/read.rb +++ b/activerecord/lib/active_record/attribute_methods/read.rb @@ -99,8 +99,9 @@ module ActiveRecord # Returns the value of the attribute identified by <tt>attr_name</tt> after it has been typecast (for example, # "2004-12-12" in a data column is cast to a date object, like Date.new(2004, 12, 12)). def read_attribute(attr_name) - if respond_to? "_#{attr_name}" - send "_#{attr_name}" if @attributes.has_key?(attr_name.to_s) + method = "_#{attr_name}" + if respond_to? method + send method if @attributes.has_key?(attr_name.to_s) else _read_attribute attr_name end |