Sha256: 817c9bfd595387d8415f9e7231d0bfdad710aa18a300a47fa237c10d5aac857f

Contents?: true

Size: 583 Bytes

Versions: 1

Compression:

Stored size: 583 Bytes

Contents

# frozen_string_literal: true

module AcidicJob
  class Context
    def initialize(execution)
      @execution = execution
    end

    def []=(key, value)
      AcidicJob.instrument(:set_context, key: key, value: value) do
        AcidicJob::Value.upsert(
          { execution_id: @execution.id,
            key: key,
            value: value },
          unique_by: %i[execution_id key]
        )
      end
    end

    def [](key)
      AcidicJob.instrument(:get_context, key: key) do
        @execution.values.select(:value).find_by(key: key)&.value
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
acidic_job-1.0.0.rc1 lib/acidic_job/context.rb