Module: Cosmo::ActiveJobAdapter::Options::ClassMethods

Defined in:
lib/cosmo/active_job/options.rb

Instance Method Summary collapse

Instance Method Details

#cosmo_options(**opts) ⇒ Object

Set Cosmo-specific options for this job class. Merges with any options inherited from a superclass. Raises ArgumentError for unknown keys.

Raises:

  • (::ArgumentError)


30
31
32
33
34
35
# File 'lib/cosmo/active_job/options.rb', line 30

def cosmo_options(**opts)
  unknown = opts.keys - Cosmo::ActiveJobAdapter::Options::VALID_OPTIONS
  raise ::ArgumentError, "Unknown cosmo_options key(s): #{unknown.join(", ")}" if unknown.any?

  @cosmo_options = get_cosmo_options.merge(opts)
end

#get_cosmo_optionsObject

Returns the resolved options, walking up the inheritance chain.



38
39
40
41
42
43
44
45
46
# File 'lib/cosmo/active_job/options.rb', line 38

def get_cosmo_options # rubocop:disable Naming/AccessorMethodName
  if @cosmo_options
    @cosmo_options.dup
  elsif superclass.respond_to?(:get_cosmo_options)
    superclass.get_cosmo_options
  else
    {}
  end
end