Module: AcidicJob::Staging

Extended by:
ActiveSupport::Concern
Defined in:
lib/acidic_job/staging.rb

Instance Method Summary collapse

Instance Method Details

#delete_staged_job_recordObject



10
11
12
13
14
15
16
17
# File 'lib/acidic_job/staging.rb', line 10

def delete_staged_job_record
  return unless was_staged_job?

  staged_job_run.delete
  true
rescue ActiveRecord::RecordNotFound
  true
end

#identifierObject



31
32
33
34
35
36
37
38
39
# File 'lib/acidic_job/staging.rb', line 31

def identifier
  return jid if defined?(jid) && !jid.nil?
  return job_id if defined?(job_id) && !job_id.nil?

  # might be defined already in `with_acidity` method
  @__acidic_job_idempotency_key ||= IdempotencyKey.value_for(self, @__acidic_job_args, @__acidic_job_kwargs)

  @__acidic_job_idempotency_key
end

#staged_job_runObject



23
24
25
26
27
28
29
# File 'lib/acidic_job/staging.rb', line 23

def staged_job_run
  # "STG_#{idempotency_key}__#{encoded_global_id}"
  encoded_global_id = identifier.split("__").last
  staged_job_gid = "gid://#{Base64.decode64(encoded_global_id)}"

  GlobalID::Locator.locate(staged_job_gid)
end

#was_staged_job?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/acidic_job/staging.rb', line 19

def was_staged_job?
  identifier.start_with? "STG_"
end