diff options
author | Michael Koziarski <michael@koziarski.com> | 2007-09-17 09:29:02 +0000 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2007-09-17 09:29:02 +0000 |
commit | acbec3e565909da5811488e88066a01f71b68a94 (patch) | |
tree | 3918c0ee69cdd55d82286de127c4f6bc2b0d27e4 /activerecord/lib | |
parent | bfb906a905a1e8774e438b10e8cf703a829b55dc (diff) | |
download | rails-acbec3e565909da5811488e88066a01f71b68a94.tar.gz rails-acbec3e565909da5811488e88066a01f71b68a94.tar.bz2 rails-acbec3e565909da5811488e88066a01f71b68a94.zip |
Ensure that custom mutators aren't redefined by define_attribute_methods. [Koz]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7500 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/attribute_methods.rb | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb index 657abc8b8d..460b5ff244 100644 --- a/activerecord/lib/active_record/attribute_methods.rb +++ b/activerecord/lib/active_record/attribute_methods.rb @@ -58,7 +58,7 @@ module ActiveRecord def define_attribute_methods return if generated_methods? columns_hash.each do |name, column| - unless instance_methods.include?(name) + unless instance_method_already_defined?(name) if self.serialized_attributes[name] define_read_method_for_serialized_attribute(name) else @@ -66,15 +66,22 @@ module ActiveRecord end end - unless instance_methods.include?("#{name}=") + unless instance_method_already_defined?("#{name}=") define_write_method(name.to_sym) end - unless instance_methods.include?("#{name}?") + unless instance_method_already_defined?("#{name}?") define_question_method(name) end end end + + def instance_method_already_defined?(method_name) + method_defined?(method_name) || + private_method_defined?(method_name) || + protected_method_defined?(method_name) + end + alias :define_read_methods :define_attribute_methods |