aboutsummaryrefslogtreecommitdiffstats
path: root/activeresource/lib/active_resource/observing.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activeresource/lib/active_resource/observing.rb')
-rw-r--r--activeresource/lib/active_resource/observing.rb13
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