Sha256: 4f28ddb1aafdcc3949f366cae2638e5b96a0a31174b641c6c40fea02020d9ce2

Contents?: true

Size: 574 Bytes

Versions: 3

Compression:

Stored size: 574 Bytes

Contents

require 'active_support'
require 'active_model/callbacks'

module ActiveEncode
  module Polling
    extend ActiveSupport::Concern

    POLLING_WAIT_TIME = 10.seconds.freeze

    CALLBACKS = [
        :after_status_update, :after_failed, :after_cancelled, :after_completed
    ].freeze

    included do
      extend ActiveModel::Callbacks

      define_model_callbacks :status_update, :failed, :cancelled, :completed, only: :after

      after_create do |encode|
        ActiveEncode::PollingJob.set(wait: POLLING_WAIT_TIME).perform_later(encode)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
active_encode-0.5.0 lib/active_encode/polling.rb
active_encode-0.4.1 lib/active_encode/polling.rb
active_encode-0.4 lib/active_encode/polling.rb