Sha256: fda7708cc5514e137358d9571658a4dc1105a2464879128aa1fa13370894a0fa

Contents?: true

Size: 684 Bytes

Versions: 2

Compression:

Stored size: 684 Bytes

Contents

module QC
  module QueueCallbacks
    extend ActiveSupport::Concern

    included do
      include ActiveSupport::Callbacks
      define_callbacks :enqueue, :delete, :scope => [:kind, :name]
      set_callback :enqueue, :after, QC::AutoScale.new
      set_callback :delete, :after, QC::AutoScale.new
      
      alias_method_chain :enqueue, :callbacks
      alias_method_chain :delete, :callbacks
    end

    def enqueue_with_callbacks(method, *args)
      run_callbacks :enqueue do
        enqueue_without_callbacks(method, *args)
      end
    end

    def delete_with_callbacks(id)
      run_callbacks :delete do
        delete_without_callbacks(id)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
heroku-qc-autoscale-0.0.2 lib/qc/callbacks.rb
heroku-qc-autoscale-0.0.1 lib/qc/callbacks.rb