Skip to content

Commit

Permalink
only calculate method name once
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Jun 30, 2011
1 parent f261ef4 commit f7bd07b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions activerecord/lib/active_record/attribute_methods/read.rb
Expand Up @@ -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
Expand Down

0 comments on commit f7bd07b

Please sign in to comment.