Permalink
Browse files

added docs to alias_attribute method in 3-2-stable

  • Loading branch information...
Francesco Rodriguez
Francesco Rodriguez committed May 8, 2012
1 parent ad4d408 commit d7376f5ab15f5924ede75eea80b2461a1c192cc7
Showing with 11 additions and 0 deletions.
  1. +11 −0 activemodel/lib/active_model/attribute_methods.rb
@@ -220,6 +220,17 @@ def attribute_method_affix(*affixes)
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

0 comments on commit d7376f5

Please sign in to comment.