Sha256: e8c71773015d7ab6e6a257eee75836fd43a4af07d69351689267e38ca1e84a8b

Contents?: true

Size: 795 Bytes

Versions: 5

Compression:

Stored size: 795 Bytes

Contents

require 'rails/observers/active_model/observing'

module ActiveResource
  module Observing
    def self.prepended(context)
      context.include ActiveModel::Observing
    end

    def create(*)
      notify_observers(:before_create)
      if result = super
        notify_observers(:after_create)
      end
      result
    end

    def save(*)
      notify_observers(:before_save)
      if result = super
        notify_observers(:after_save)
      end
      result
    end

    def update(*)
      notify_observers(:before_update)
      if result = super
        notify_observers(:after_update)
      end
      result
    end

    def destroy(*)
      notify_observers(:before_destroy)
      if result = super
        notify_observers(:after_destroy)
      end
      result
    end
  end
end

Version data entries

5 entries across 4 versions & 3 rubygems

Version Path
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.1.0/gems/rails-observers-0.1.5/lib/rails/observers/active_resource/observing.rb
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/rails-observers-0.1.5/lib/rails/observers/active_resource/observing.rb
rails-observers-0.1.5 lib/rails/observers/active_resource/observing.rb
rails-observers-0.1.4 lib/rails/observers/active_resource/observing.rb
rails-observers-hp-0.1.3 lib/rails/observers/active_resource/observing.rb