Permalink
Browse files

Base#[] and Base#[]= are aliases so implement them as aliases :)

  • Loading branch information...
1 parent 42c51b8 commit 21eadc1b3f2eb818a4833381ee0a6cfa205f2955 @spastorino spastorino committed Dec 2, 2010
Showing with 11 additions and 13 deletions.
  1. +11 −13 activerecord/lib/active_record/base.rb
@@ -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).
#
@@ -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

0 comments on commit 21eadc1

Please sign in to comment.