Sha256: 43e3716eb0d66e45acdd1e39e4924f3b4f99e11cf87a88e48112245cd0d82edd

Contents?: true

Size: 602 Bytes

Versions: 2

Compression:

Stored size: 602 Bytes

Contents

# frozen_string_literal: true
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

2 entries across 2 versions & 1 rubygems

Version Path
active_encode-0.7.0 lib/active_encode/polling.rb
active_encode-0.6.0 lib/active_encode/polling.rb