Module: Exekutor::Asynchronous

Extended by:
ActiveSupport::Concern
Defined in:
lib/exekutor/asynchronous.rb

Overview

Mixin to let methods be executed asynchronously by active job

Examples:

Mark methods as asynchronous

class MyClass
  include Exekutor::Asynchronous

  def instance_method
    puts "This will be performed by an Exekutor worker"
  end
  perform_asynchronously :instance_method

  def self.class_method(str)
    puts "This will also be performed by an Exekutor worker: #{str}"
  end
  perform_asynchronously :class_method, class_method: true
end

Defined Under Namespace

Classes: AsyncMethodJob, Error

Class Method Summary collapse

Class Method Details

.validate_args(delegate, method, *args, **kwargs) ⇒ ArgumentError?

Validates whether the given arguments match the expected parameters for method

Parameters:

  • delegate (Object)

    the object the method will be called on

  • method (Symbol)

    the method that will be called on delegate

  • args (Array)

    the arguments that will be given to the method

  • kwargs (Hash)

    the keyword arguments that will be given to the method

Returns:

  • (ArgumentError, nil)

    nil if the keywords are valid; an ArgumentError otherwise



103
104
105
106
107
108
# File 'lib/exekutor/asynchronous.rb', line 103

def self.validate_args(delegate, method, *args, **kwargs)
  error = ArgumentValidator.new(delegate, method).validate(args, kwargs)
  return nil unless error

  ArgumentError.new(error)
end