module ConeyIsland::Performer::ClassMethods

Public Instance Methods

get_coney_settings() click to toggle source
# File lib/coney_island/performer.rb, line 46
def get_coney_settings
  self.coney_island_settings ||= ConeyIsland.default_settings
end
set_background_defaults(options = {}) click to toggle source

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)

# 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

Protected Instance Methods

method_missing(method_name, *args) click to toggle source
Calls superclass method
# 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