Skip to content

Commit

Permalink
Base#[] and Base#[]= are aliases so implement them as aliases :)
Browse files Browse the repository at this point in the history
  • Loading branch information
spastorino committed Dec 2, 2010
1 parent 42c51b8 commit 21eadc1
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions activerecord/lib/active_record/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1460,19 +1460,6 @@ def attribute_names
@attributes.keys
end

# 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)).
# (Alias for the protected read_attribute method).
def [](attr_name)
read_attribute(attr_name)
end

# Updates the attribute identified by <tt>attr_name</tt> with the specified +value+.
# (Alias for the protected write_attribute method).
def []=(attr_name, value)
write_attribute(attr_name, value)
end

# Allows you to set all the attributes at once by passing in a hash with keys
# matching the attribute names (which again matches the column names).
#
Expand Down Expand Up @@ -1873,6 +1860,17 @@ def clear_timestamp_attributes
include Aggregations, Transactions, Reflection, Serialization

NilClass.add_whiner(self) if NilClass.respond_to?(:add_whiner)

# 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)).
# (Alias for the protected read_attribute method).
alias [] read_attribute

# Updates the attribute identified by <tt>attr_name</tt> with the specified +value+.
# (Alias for the protected write_attribute method).
alias []= write_attribute

public :[], :[]=
end
end

Expand Down

0 comments on commit 21eadc1

Please sign in to comment.