Module: ConeyIsland::Performer::ClassMethods

Defined in:
lib/coney_island/performer.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args) ⇒ Object (protected)



52
53
54
55
56
57
58
59
60
# File 'lib/coney_island/performer.rb', line 52

def method_missing(method_name, *args)
  method_str = method_name.to_s
  if method_str =~ /.*_async$/
    synchronous_method = method_str.sub(/_async$/, '')
    ConeyIsland.submit(self, synchronous_method, args: args, highlander: get_coney_settings[:highlander])
  else
    super
  end
end

Instance Method Details

#get_coney_settingsObject



46
47
48
# File 'lib/coney_island/performer.rb', line 46

def get_coney_settings
  self.coney_island_settings ||= ConeyIsland.default_settings
end

#set_background_defaults(options = {}) ⇒ Object

Sets inheritable class defaults for ConeyIsland. Valid options:

:work_queue - use a named queue for this class.
:delay - Delay execution of the job on the worker. The delay value is
  a number of seconds.
:timeout - Timeout the job with retry. The timeout value is a number
  of seconds. By default ConeyIsland will retry 3 times before bailing
  out.
:highlander - There can only be one job with the same arguments per

request lifecycle. This makes it so that even if you enqueue the same job with the same arguments twice, it will only fire once. Only makes sense when caching jobs (like in a Rails app where you can cache jobs and flush them all at once after the end of the request)



41
42
43
44
# File 'lib/coney_island/performer.rb', line 41

def set_background_defaults(options = {})
  options = options.dup.symbolize_keys.slice(:work_queue, :delay, :timeout, :highlander)
  self.coney_island_settings = get_coney_settings.merge(options)
end