aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/base.rb
diff options
context:
space:
mode:
authorSantiago Pastorino <santiago@wyeworks.com>2010-12-02 20:05:06 -0200
committerSantiago Pastorino <santiago@wyeworks.com>2010-12-02 20:28:28 -0200
commit21eadc1b3f2eb818a4833381ee0a6cfa205f2955 (patch)
treea3353dfa114f1d4d61e9447825b2fb4ada792c9b /activerecord/lib/active_record/base.rb
parent42c51b8527e49ae2d7a0f6cc009e53865b7910c1 (diff)
downloadrails-21eadc1b3f2eb818a4833381ee0a6cfa205f2955.tar.gz
rails-21eadc1b3f2eb818a4833381ee0a6cfa205f2955.tar.bz2
rails-21eadc1b3f2eb818a4833381ee0a6cfa205f2955.zip
Base#[] and Base#[]= are aliases so implement them as aliases :)
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rw-r--r--activerecord/lib/active_record/base.rb24
1 files changed, 11 insertions, 13 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 6573cd5e89..ba7f6f0129 100644
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -1460,19 +1460,6 @@ MSG
@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 @@ MSG
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