1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

AMo overrides alias_attribute and manages aliasing all known attribute method matchers

This commit is contained in:
Joshua Peek 2009-08-10 11:58:44 -05:00
parent d574cb31f0
commit 391f978acd
2 changed files with 10 additions and 17 deletions

View file

@ -133,6 +133,16 @@ module ActiveModel
undefine_attribute_methods undefine_attribute_methods
end 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) def define_attribute_methods(attr_names)
return if attribute_methods_generated? return if attribute_methods_generated?
attr_names.each do |attr_name| attr_names.each do |attr_name|

View file

@ -182,23 +182,6 @@ module ActiveRecord
old != value old != value
end end
module ClassMethods
def self.extended(base)
class << base
alias_method_chain :alias_attribute, :dirty
end
end
def alias_attribute_with_dirty(new_name, old_name)
alias_attribute_without_dirty(new_name, old_name)
DIRTY_AFFIXES.each do |affixes|
module_eval <<-STR, __FILE__, __LINE__+1
def #{affixes[:prefix]}#{new_name}#{affixes[:suffix]}; self.#{affixes[:prefix]}#{old_name}#{affixes[:suffix]}; end # def reset_subject!; self.reset_title!; end
STR
end
end
end
end end
end end
end end