Class: AcidicJob::Context
- Inherits:
-
Object
- Object
- AcidicJob::Context
- Defined in:
- lib/acidic_job/context.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
-
#initialize(execution) ⇒ Context
constructor
A new instance of Context.
Constructor Details
#initialize(execution) ⇒ Context
Returns a new instance of Context.
5 6 7 |
# File 'lib/acidic_job/context.rb', line 5 def initialize(execution) @execution = execution end |
Instance Method Details
#[](key) ⇒ Object
20 21 22 23 24 |
# File 'lib/acidic_job/context.rb', line 20 def [](key) AcidicJob.instrument(:get_context, key: key) do @execution.values.select(:value).find_by(key: key)&.value end end |
#[]=(key, value) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/acidic_job/context.rb', line 9 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 |