Sha256: cf6fb83d8a7ed127e6097bd90c4a9a0dbe23d253fa45a85d10d1833e962d67fb

Contents?: true

Size: 673 Bytes

Versions: 1

Compression:

Stored size: 673 Bytes

Contents

require 'active_record/base'

module Backgrounded
  module ActiveRecordExtension
    extend ActiveSupport::Concern

    module ClassMethods
      # execute a method in the background after the object is committed to the database
      # @option options [Hash] :backgrounded (optional) options to pass into the backgrounded handler
      # @see after_commit
      def after_commit_backgrounded(method_name, options={})
        self.after_commit options.except(:backgrounded) do |instance|
          instance.backgrounded(options[:backgrounded]).send(method_name)
        end
      end
    end
  end
end
ActiveRecord::Base.send(:include, Backgrounded::ActiveRecordExtension)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
backgrounded-2.1.0 lib/backgrounded/active_record_extension.rb