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
challah-0.6.2 vendor/bundle/gems/activeresource-3.2.2/lib/active_resource/observing.rb
challah-0.6.2 vendor/bundle/gems/activeresource-3.2.6/lib/active_resource/observing.rb
challah-0.6.2 vendor/bundle/gems/activeresource-3.2.3/lib/active_resource/observing.rb
challah-0.6.2 vendor/bundle/gems/activeresource-3.2.5/lib/active_resource/observing.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/vendor/bundle/ruby/1.9.1/gems/activeresource-3.2.3/lib/active_resource/observing.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/activeresource-3.2.3/lib/active_resource/observing.rb
initforthe-cookies-0.0.1 vendor/bundle/gems/activeresource-3.2.6/lib/active_resource/observing.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/activeresource-3.2.3/lib/active_resource/observing.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/vendor/bundle/ruby/1.9.1/gems/activeresource-3.2.3/lib/active_resource/observing.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/vendor/bundle/ruby/1.9.1/gems/activeresource-3.2.3/lib/active_resource/observing.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/activeresource-3.2.3/lib/active_resource/observing.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/vendor/bundle/ruby/1.9.1/gems/activeresource-3.2.3/lib/active_resource/observing.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/activeresource-3.2.3/lib/active_resource/observing.rb
rails-uploader-0.0.4 vendor/bundle/ruby/1.9.1/gems/activeresource-3.2.3/lib/active_resource/observing.rb
rails-uploader-0.0.4 vendor/bundle/ruby/1.9.1/gems/activeresource-3.2.6/lib/active_resource/observing.rb
activeresource-3.2.6 lib/active_resource/observing.rb
activeresource-3.1.6 lib/active_resource/observing.rb
challah-0.6.1 vendor/bundle/gems/activeresource-3.2.1/lib/active_resource/observing.rb
challah-0.6.1 vendor/bundle/gems/activeresource-3.2.3/lib/active_resource/observing.rb
challah-0.6.1 vendor/bundle/gems/activeresource-3.2.2/lib/active_resource/observing.rb