module Activejob::PerformLater::Util
Public Instance Methods
perform_method_later(obj, method_name, options)
click to toggle source
# File lib/activejob/perform_later/util.rb, line 17 def perform_method_later(obj, method_name, options) raise ArgumentError, "#{self} must respond to `#{method_name}`" unless obj.respond_to?(method_name) aliased_method, punctuation = method_name.to_s.sub(/([?!=])$/, ""), $1 now_method, later_method = "#{aliased_method}_now#{punctuation}", "#{aliased_method}_later#{punctuation}" obj.singleton_class.send(:define_method, later_method) do |*args| Job.new(::Activejob::PerformLater::Util.proxiable_object(obj), now_method, args).enqueue options end obj.singleton_class.send(:alias_method, now_method, method_name) obj.singleton_class.send(:alias_method, method_name, later_method) end
perform_methods_later(obj, method_names, options)
click to toggle source
# File lib/activejob/perform_later/util.rb, line 10 def perform_methods_later(obj, method_names, options) raise ArgumentError, "You can only declare class methods as delayed" unless obj.class == Class || obj.class == Module method_names.each do |method_name| perform_method_later(obj, method_name, options) end end
proxiable_object(obj)
click to toggle source
# File lib/activejob/perform_later/util.rb, line 28 def proxiable_object(obj) obj.class == ::Class || obj.class == ::Module ? obj.name : obj end
proxy_calls(obj, options)
click to toggle source
# File lib/activejob/perform_later/util.rb, line 6 def proxy_calls(obj, options) Proxy.new(obj, options) end