aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2009-08-10 11:58:44 -0500
committerJoshua Peek <josh@joshpeek.com>2009-08-10 11:58:44 -0500
commit391f978acdf9b4789f9ac301a72b99e05ace64f1 (patch)
tree19fe27f508d5411ceb98c0cb6378e366fa5cbecd /activemodel
parentd574cb31f0406e267edb0e9ed1ffc7998d0da1ee (diff)
downloadrails-391f978acdf9b4789f9ac301a72b99e05ace64f1.tar.gz
rails-391f978acdf9b4789f9ac301a72b99e05ace64f1.tar.bz2
rails-391f978acdf9b4789f9ac301a72b99e05ace64f1.zip
AMo overrides alias_attribute and manages aliasing all known attribute method matchers
Diffstat (limited to 'activemodel')
-rw-r--r--activemodel/lib/active_model/attribute_methods.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/activemodel/lib/active_model/attribute_methods.rb b/activemodel/lib/active_model/attribute_methods.rb
index 1ae042e00f..1091ad3095 100644
--- a/activemodel/lib/active_model/attribute_methods.rb
+++ b/activemodel/lib/active_model/attribute_methods.rb
@@ -133,6 +133,16 @@ module ActiveModel
undefine_attribute_methods
end
+ def alias_attribute(new_name, old_name)
+ attribute_method_matchers.each do |matcher|
+ module_eval <<-STR, __FILE__, __LINE__+1
+ def #{matcher.method_name(new_name)}(*args)
+ send(:#{matcher.method_name(old_name)}, *args)
+ end
+ STR
+ end
+ end
+
def define_attribute_methods(attr_names)
return if attribute_methods_generated?
attr_names.each do |attr_name|