Module: Quebert::AsyncSender::Promise::DSL

Defined in:
lib/quebert/async_sender/promise.rb

Overview

Methods/DSL that we mix into classes, objects, etc. so that we can easily enqueue jobs to these.

Instance Method Summary collapse

Instance Method Details

#async(opts = {}) ⇒ Object


38
39
40
# File 'lib/quebert/async_sender/promise.rb', line 38

def async(opts={})
  Promise.new(self, opts) { |job| job.enqueue }
end

#async_send(*args) ⇒ Object

Legacy way of enqueueing jobs.


43
44
45
46
47
48
49
50
# File 'lib/quebert/async_sender/promise.rb', line 43

def async_send(*args)
  meth = args.shift
  beanstalk = args.last.delete(:beanstalk) if args.last.is_a?(::Hash)

  Quebert.deprecate "#async_send should be called via #{self.class.name}.async(#{beanstalk.inspect}).#{args.first}(#{args.map(&:inspect).join(', ')})" do
    async(beanstalk || {}).send(meth, *args)
  end
end