Sha256: 35e5a2e9dc0be0e094c91b5519858be383bb9a9f5966d92922c249ff7b6a3400

Contents?: true

Size: 916 Bytes

Versions: 158

Compression:

Stored size: 916 Bytes

Contents

module ActiveResource
  module Observing
    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})
            end
            result
          end
        EOS
        alias_method_chain(method, :notifications)
      end
    end
  end
end

Version data entries

158 entries across 132 versions & 11 rubygems

Version Path
activeresource-3.2.22.5 lib/active_resource/observing.rb
activeresource-3.2.22.4 lib/active_resource/observing.rb
activeresource-3.2.22.3 lib/active_resource/observing.rb
activeresource-3.2.22.2 lib/active_resource/observing.rb
activeresource-3.2.22.1 lib/active_resource/observing.rb
active_mailer-0.0.10 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/activeresource-3.2.12/lib/active_resource/observing.rb
activeresource-3.2.22 lib/active_resource/observing.rb
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/activeresource-3.2.12/lib/active_resource/observing.rb
activeresource-3.2.21 lib/active_resource/observing.rb
activeresource-3.2.20 lib/active_resource/observing.rb
activeresource-3.2.19 lib/active_resource/observing.rb
activeresource-3.2.18 lib/active_resource/observing.rb
activeresource-3.2.17 lib/active_resource/observing.rb
activeresource-3.2.16 lib/active_resource/observing.rb
activeresource-3.2.15 lib/active_resource/observing.rb
activeresource-3.2.15.rc3 lib/active_resource/observing.rb
activeresource-3.2.15.rc2 lib/active_resource/observing.rb
activeresource-3.2.15.rc1 lib/active_resource/observing.rb
activeresource-3.2.14 lib/active_resource/observing.rb
activeresource-3.2.14.rc2 lib/active_resource/observing.rb