diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2009-09-21 21:14:04 +0100 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-09-21 21:14:04 +0100 |
commit | 340be9bddd8e5902e0218a0101a40a17a4afd558 (patch) | |
tree | ef4de25f3f8eb610dc2235f0762b01cb1d464efd /activeresource/lib/active_resource/observing.rb | |
parent | b31cdb55422226cd45a2234a4b54986f1f611151 (diff) | |
parent | 1bbb9b2db05730194edfd7d2cef9f5fcb9d79e50 (diff) | |
download | rails-340be9bddd8e5902e0218a0101a40a17a4afd558.tar.gz rails-340be9bddd8e5902e0218a0101a40a17a4afd558.tar.bz2 rails-340be9bddd8e5902e0218a0101a40a17a4afd558.zip |
Merge commit 'mainstream/master'
Diffstat (limited to 'activeresource/lib/active_resource/observing.rb')
-rw-r--r-- | activeresource/lib/active_resource/observing.rb | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/activeresource/lib/active_resource/observing.rb b/activeresource/lib/active_resource/observing.rb index 94836f4bb1..3c74d49c80 100644 --- a/activeresource/lib/active_resource/observing.rb +++ b/activeresource/lib/active_resource/observing.rb @@ -4,7 +4,18 @@ module ActiveResource include ActiveModel::Observing included do - wrap_with_notifications :create, :save, :update, :destroy + %w( create save update destroy ).each do |method| + class_eval(<<-EOS, __FILE__, __LINE__ + 1) + def #{method}_with_notifications(*args, &block) + notify_observers(:before_#{method}) + if result = #{method}_without_notifications(*args, &block) + notify_observers(:after_#{method}) + end + result + end + EOS + alias_method_chain(method, :notifications) + end end end end |