Permalink
Browse files

only calculate method name once

  • Loading branch information...
1 parent f261ef4 commit f7bd07b62a9372f7b370dd6959dec39e92e77dfe @tenderlove tenderlove committed Jun 30, 2011
Showing with 3 additions and 2 deletions.
  1. +3 −2 activerecord/lib/active_record/attribute_methods/read.rb
@@ -99,8 +99,9 @@ def _#{method_name}
# 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

0 comments on commit f7bd07b

Please sign in to comment.