Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

only calculate method name once

  • Loading branch information...
commit f7bd07b62a9372f7b370dd6959dec39e92e77dfe 1 parent f261ef4
@tenderlove tenderlove authored
Showing with 3 additions and 2 deletions.
  1. +3 −2 activerecord/lib/active_record/attribute_methods/read.rb
View
5 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
Please sign in to comment.
Something went wrong with that request. Please try again.