Module: Delayed::MessageSending

Defined in:
lib/delayed/message_sending.rb

Defined Under Namespace

Modules: ClassMethods Classes: DelayProxy

Instance Method Summary collapse

Instance Method Details

#__calculate_sender_for_delayObject


99
100
101
102
103
# File 'lib/delayed/message_sending.rb', line 99

def __calculate_sender_for_delay
  # enforce public send in dev and test, but not prod (since it uses
  # debug APIs, it's expensive)
  return sender(1) if ::Rails.env.test? || ::Rails.env.development?
end

#delay(sender: nil, **enqueue_args) ⇒ Object


86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/delayed/message_sending.rb', line 86

def delay(sender: nil, **enqueue_args)
  # support procs/methods as enqueue arguments
  enqueue_args.each do |k,v|
    if v.respond_to?(:call)
      enqueue_args[k] = v.call(self)
    end
  end

  sender ||= __calculate_sender_for_delay

  DelayProxy.new(self, sender: sender, **enqueue_args)
end