Sha256: fae9c99b208e03fff24634d563c486bda1b8c6cefd9446645ab1f5f0899484b5

Contents?: true

Size: 598 Bytes

Versions: 2

Compression:

Stored size: 598 Bytes

Contents

require 'active_support/concern'

module Backgrounded
  module ActiveRecordExtension
    extend ActiveSupport::Concern

    class_methods do
      # 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={})
        after_commit options.except(:backgrounded) do |instance|
          instance.backgrounded(options[:backgrounded]).send(method_name)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
backgrounded-2.1.2 lib/backgrounded/active_record_extension.rb
backgrounded-2.1.1 lib/backgrounded/active_record_extension.rb