diff options
author | Vijay Dev <vijaydev.cse@gmail.com> | 2012-05-08 23:54:47 +0530 |
---|---|---|
committer | Vijay Dev <vijaydev.cse@gmail.com> | 2012-05-08 23:54:47 +0530 |
commit | 7e26f7f0f7e3c230c333e1b265727a9b8cf7c91f (patch) | |
tree | 877cf41cae8181eeae5ce4a0c17fee4b1256380d /activemodel/lib/active_model | |
parent | f31613a0312bfb2529d0ac262337cd7338cb868d (diff) | |
download | rails-7e26f7f0f7e3c230c333e1b265727a9b8cf7c91f.tar.gz rails-7e26f7f0f7e3c230c333e1b265727a9b8cf7c91f.tar.bz2 rails-7e26f7f0f7e3c230c333e1b265727a9b8cf7c91f.zip |
simplify the alias_attribute example [ci skip]
Diffstat (limited to 'activemodel/lib/active_model')
-rw-r--r-- | activemodel/lib/active_model/attribute_methods.rb | 21 |
1 files changed, 1 insertions, 20 deletions
diff --git a/activemodel/lib/active_model/attribute_methods.rb b/activemodel/lib/active_model/attribute_methods.rb index 59977b6142..25d5d84ce6 100644 --- a/activemodel/lib/active_model/attribute_methods.rb +++ b/activemodel/lib/active_model/attribute_methods.rb @@ -183,34 +183,15 @@ module ActiveModel # Allows you to make aliases for attributes. # - # For example: - # # class Person - # - # include ActiveModel::AttributeMethods # attr_accessor :name - # attribute_method_prefix 'clear_' - # - # define_attribute_methods [:name] - # - # private - # - # def clear_attribute(attr) - # send("#{attr}=", nil) - # end - # end - # - # class Person - # attr_accessor :nickname - # # alias_attribute :nickname, :name # end # # person = Person.new # person.nickname = "Bob" # person.nickname # => "Bob" - # person.clear_nickname - # person.nickname # => nil + # 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 |