Sha256: fe4094610a8074f2b21609dc81099ef2a4aba99a538484391bfadb93eaba5bbc

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

require 'much-plugin'

require 'mr/after_commit/record_procs_methods'
require 'mr/record'

module MR; end
module MR::AfterCommit

  module Record
    include MuchPlugin

    plugin_included do
      include MR::Record
      include RecordProcsMethods
      include InstanceMethods

      after_commit :mr_after_commit_call_procs_for_create,  :on => :create
      after_commit :mr_after_commit_call_procs_for_update,  :on => :update
      after_commit :mr_after_commit_call_procs_for_destroy, :on => :destroy
    end

    module InstanceMethods

      private

      # ActiveRecord runs `after_save` after `after_create`, so run the save
      # procs after the create procs
      def mr_after_commit_call_procs_for_create
        mr_after_commit_call_procs(:create)
        mr_after_commit_call_procs(:save)
      end

      # ActiveRecord runs `after_save` after `after_update`, so run the save
      # procs after the update procs
      def mr_after_commit_call_procs_for_update
        mr_after_commit_call_procs(:update)
        mr_after_commit_call_procs(:save)
      end

      def mr_after_commit_call_procs_for_destroy
        mr_after_commit_call_procs(:destroy)
      end

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mr-0.35.2 lib/mr/after_commit/record.rb