lib/active_resource/observing.rb in activeresource-3.0.20 vs lib/active_resource/observing.rb in activeresource-3.1.0.beta1
- old
+ new
@@ -3,9 +3,17 @@
extend ActiveSupport::Concern
include ActiveModel::Observing
included do
%w( create save update destroy ).each do |method|
+ # def create_with_notifications(*args, &block)
+ # notify_observers(:before_create)
+ # if result = create_without_notifications(*args, &block)
+ # notify_observers(:after_create)
+ # end
+ # result
+ # end
+ # alias_method_chain(create, :notifications)
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})