Module: ActiveJob::Temporal::ConfiguredJobCompatibility

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

Defined Under Namespace

Classes: ExtractedConfiguredJob

Constant Summary collapse

SUPPORTED_ACTIVE_JOB_MAJOR_MINOR =
[
  [7, 2],
  [8, 0],
  [8, 1]
].freeze
FEATURE_REPLACEMENTS =
{
  "chain" => "ActiveJob::Temporal.job",
  "child_workflows" => "ActiveJob::Temporal.job",
  "conditional_enqueue" => "JobClass.perform_later_if or an explicit condition before " \
                           "JobClass.set(...).perform_later"
}.freeze

Class Method Summary collapse

Class Method Details

.active_job_class?(job_class) ⇒ Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/activejob/temporal/configured_job_compatibility.rb', line 59

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

.active_job_versionObject



98
99
100
101
102
# File 'lib/activejob/temporal/configured_job_compatibility.rb', line 98

def active_job_version
  return ActiveJob.gem_version if ActiveJob.respond_to?(:gem_version)

  Gem::Version.new(ActiveJob::VERSION::STRING)
end

.configured_job?(value) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/activejob/temporal/configured_job_compatibility.rb', line 38

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

.job_class(value, feature:) ⇒ Object



34
35
36
# File 'lib/activejob/temporal/configured_job_compatibility.rb', line 34

def job_class(value, feature:)
  extract(value, feature: feature)&.job_class
end

.log_private_api(feature) ⇒ Object



110
111
112
113
114
115
116
117
118
# File 'lib/activejob/temporal/configured_job_compatibility.rb', line 110

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

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



24
25
26
27
28
29
30
31
32
# File 'lib/activejob/temporal/configured_job_compatibility.rb', line 24

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

  {
    job_class: configured_job.job_class.name,
    options: normalize_options.call(configured_job.options)
  }
end