Module: ActiveJob::Temporal::ConfiguredJobCompatibility

Defined in:
lib/activejob/temporal/configured_job_compatibility.rb

Class Method Summary collapse

Class Method Details

.active_job_class?(job_class) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/activejob/temporal/configured_job_compatibility.rb', line 29

def active_job_class?(job_class)
  job_class.is_a?(Class) && job_class < ActiveJob::Base && job_class.name
end

.configured_job?(value) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/activejob/temporal/configured_job_compatibility.rb', line 25

def configured_job?(value)
  defined?(ActiveJob::ConfiguredJob) && value.is_a?(ActiveJob::ConfiguredJob)
end

.log_private_api(feature) ⇒ Object



33
34
35
36
37
38
39
40
41
# File 'lib/activejob/temporal/configured_job_compatibility.rb', line 33

def log_private_api(feature)
  ActiveJob::Temporal::Logger.warn(
    "active_job_configured_job_private_api",
    feature: feature,
    replacement: "ActiveJob::Temporal.job"
  )
rescue StandardError
  nil
end

.payload(value, feature:, normalize_options:) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/activejob/temporal/configured_job_compatibility.rb', line 11

def payload(value, feature:, normalize_options:)
  return unless configured_job?(value)

  log_private_api(feature)

  job_class = value.instance_variable_get(:@job_class)
  return unless active_job_class?(job_class)

  {
    job_class: job_class.name,
    options: normalize_options.call(value.instance_variable_get(:@options) || {})
  }
end