diff options
author | Josh Susser <josh@hasmanythrough.com> | 2011-11-27 14:15:40 -0800 |
---|---|---|
committer | Josh Susser <josh@hasmanythrough.com> | 2011-11-27 14:15:40 -0800 |
commit | 124c97fbe201f810d77f807ce69f37148e903c44 (patch) | |
tree | aa76767b9aadc5f60e6a25fbf5ae4b82eef4a033 /activerecord/lib/active_record/associations/builder/belongs_to.rb | |
parent | 10834e975a54b63a07896cb8a6a16c336e20a792 (diff) | |
download | rails-124c97fbe201f810d77f807ce69f37148e903c44.tar.gz rails-124c97fbe201f810d77f807ce69f37148e903c44.tar.bz2 rails-124c97fbe201f810d77f807ce69f37148e903c44.zip |
avoid warnings
This change uses Module.redefine_method as defined in ActiveSupport.
Making Module.define_method public would be as clean in the code, and
would also emit warnings when redefining an association. That is pretty
messy given current tests, so I'm leaving it for someone else to decide
what approach is better.
Diffstat (limited to 'activerecord/lib/active_record/associations/builder/belongs_to.rb')
-rw-r--r-- | activerecord/lib/active_record/associations/builder/belongs_to.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/associations/builder/belongs_to.rb b/activerecord/lib/active_record/associations/builder/belongs_to.rb index 0ca107035f..1759a41d93 100644 --- a/activerecord/lib/active_record/associations/builder/belongs_to.rb +++ b/activerecord/lib/active_record/associations/builder/belongs_to.rb @@ -25,14 +25,14 @@ module ActiveRecord::Associations::Builder name = self.name method_name = "belongs_to_counter_cache_after_create_for_#{name}" - mixin.send(:define_method, method_name) do + mixin.redefine_method(method_name) do record = send(name) record.class.increment_counter(cache_column, record.id) unless record.nil? end model.after_create(method_name) method_name = "belongs_to_counter_cache_before_destroy_for_#{name}" - mixin.send(:define_method, method_name) do + mixin.redefine_method(method_name) do record = send(name) record.class.decrement_counter(cache_column, record.id) unless record.nil? end @@ -48,7 +48,7 @@ module ActiveRecord::Associations::Builder method_name = "belongs_to_touch_after_save_or_destroy_for_#{name}" touch = options[:touch] - mixin.send(:define_method, method_name) do + mixin.redefine_method(method_name) do record = send(name) unless record.nil? |