module Services::Asyncable
Constants
- ASYNC_METHOD_SUFFIXES
Public Instance Methods
perform(*args)
click to toggle source
# File lib/services/asyncable.rb, line 42 def perform(*args) args = args.map(&Services.method(:replace_global_ids_with_records)) call_method = method(:call) # Find the first class that inherits from `Services::Base`. while !(call_method.owner < Services::Base) call_method = call_method.super_method end # If the `call` method takes any kwargs and the last argument is a hash, pass them to the method as kwargs. kwargs = if call_method.parameters.map(&:first).grep(/\Akey/).any? && args.last.is_a?(Hash) args.pop.symbolize_keys else {} end # Save args and kwargs in ivars so they can be used # in the service, i.e. for rescheduling. @_call_args, @_call_kwargs = args, kwargs call *args, **kwargs end