Sha256: 7a1e5239b1c0b20d572531f9c946ad5238484329f229410d56a5db083671b86d
Contents?: true
Size: 1.46 KB
Versions: 1
Compression:
Stored size: 1.46 KB
Contents
require 'active_support/basic_object' require 'active_support/core_ext/module/aliasing' module Delayed class DelayProxy < ActiveSupport::BasicObject def initialize(target, options) @target = target @options = options end def method_missing(method, *args) Job.create({ :payload_object => PerformableMethod.new(@target, method.to_sym, args), :priority => ::Delayed::Worker.default_priority }.merge(@options)) end end module MessageSending def delay(options = {}) DelayProxy.new(self, options) end alias __delay__ delay def send_later(method, *args) warn "[DEPRECATION] `object.send_later(:method)` is deprecated. Use `object.delay.method" __delay__.__send__(method, *args) end def send_at(time, method, *args) warn "[DEPRECATION] `object.send_at(time, :method)` is deprecated. Use `object.delay(:run_at => time).method" __delay__(:run_at => time).__send__(method, *args) end module ClassMethods def handle_asynchronously(method) aliased_method, punctuation = method.to_s.sub(/([?!=])$/, ''), $1 with_method, without_method = "#{aliased_method}_with_delay#{punctuation}", "#{aliased_method}_without_delay#{punctuation}" define_method(with_method) do |*args| delay.__send__(without_method, *args) end alias_method_chain method, :delay end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
delayed_job-2.1.0.pre2 | lib/delayed/message_sending.rb |