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



107
108
109
110
111
# File 'lib/delayed/message_sending.rb', line 107

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

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



96
97
98
99
100
101
102
103
104
105
# File 'lib/delayed/message_sending.rb', line 96

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

  sender ||= __calculate_sender_for_delay

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