aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/attribute_methods.rb
diff options
context:
space:
mode:
authorOscar Del Ben <info@oscardelben.com>2012-05-14 13:56:26 -0700
committerOscar Del Ben <info@oscardelben.com>2012-05-14 13:56:26 -0700
commitf2af398efa40dff20d4841d595bc0366660707cc (patch)
tree8af0c081de5f2d6cfc1b033c5eefa9954de569dd /activemodel/lib/active_model/attribute_methods.rb
parent59462c1e310b85569785cf5f491611e670c2755b (diff)
parent151aa9abae131f1a03513f756aeaef2fc403f9bb (diff)
downloadrails-f2af398efa40dff20d4841d595bc0366660707cc.tar.gz
rails-f2af398efa40dff20d4841d595bc0366660707cc.tar.bz2
rails-f2af398efa40dff20d4841d595bc0366660707cc.zip
Merge branch 'master' of github.com:lifo/docrails
Diffstat (limited to 'activemodel/lib/active_model/attribute_methods.rb')
-rw-r--r--activemodel/lib/active_model/attribute_methods.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/activemodel/lib/active_model/attribute_methods.rb b/activemodel/lib/active_model/attribute_methods.rb
index 97a83e58af..25d5d84ce6 100644
--- a/activemodel/lib/active_model/attribute_methods.rb
+++ b/activemodel/lib/active_model/attribute_methods.rb
@@ -180,6 +180,18 @@ module ActiveModel
undefine_attribute_methods
end
+
+ # Allows you to make aliases for attributes.
+ #
+ # class Person
+ # attr_accessor :name
+ # alias_attribute :nickname, :name
+ # end
+ #
+ # person = Person.new
+ # person.nickname = "Bob"
+ # person.nickname # => "Bob"
+ # person.name # => "Bob"
def alias_attribute(new_name, old_name)
attribute_method_matchers.each do |matcher|
matcher_new = matcher.method_name(new_name).to_s