Module: Aservice::ClassMethods

Defined in:
lib/aservice.rb

Overview

Class methods for service.

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/aservice.rb', line 35

def method_missing(method, *args)
  method = method.to_s
  if method =~ /_async$/
    method = method.sub(/.*\K_async/, '')
    perform(:async, method, args)
  elsif method =~ /_after$/
    method = method.sub(/.*\K_after/, '')
    perform(:after, method, args)
  else
    raise_no_method_error("No method: #{method} for class: #{AserviceWorker.name}")
  end
end

Instance Method Details

#call_after(jid, *args) ⇒ Object



26
27
28
29
# File 'lib/aservice.rb', line 26

def call_after(jid, *args)
  args = [] if args.nil?
  perform(:after, 'call', args.unshift(jid))
end

#call_async(*args) ⇒ Object



22
23
24
# File 'lib/aservice.rb', line 22

def call_async(*args)
  perform(:async, 'call', args)
end

#respond_to_missing?(method, _) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/aservice.rb', line 31

def respond_to_missing?(method, _)
  return false if method =~ /_(async|after)$/
end