Class: Acta::Upcaster::Context
- Inherits:
-
Object
- Object
- Acta::Upcaster::Context
- Defined in:
- lib/acta/upcaster.rb
Overview
Per-replay state carrier passed to every upcaster block. Hash-shaped by default — ‘context ||= {}`. Lives the length of one replay; never persisted across runs.
Defined Under Namespace
Classes: FailReplay
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
-
#fail_replay!(reason) ⇒ Object
Halt the replay with a clear reason.
-
#initialize ⇒ Context
constructor
A new instance of Context.
- #key?(key) ⇒ Boolean
Constructor Details
#initialize ⇒ Context
Returns a new instance of Context.
74 75 76 |
# File 'lib/acta/upcaster.rb', line 74 def initialize @store = {} end |
Instance Method Details
#[](key) ⇒ Object
78 79 80 |
# File 'lib/acta/upcaster.rb', line 78 def [](key) @store[key] ||= {} end |
#[]=(key, value) ⇒ Object
82 83 84 |
# File 'lib/acta/upcaster.rb', line 82 def []=(key, value) @store[key] = value end |
#fail_replay!(reason) ⇒ Object
Halt the replay with a clear reason. Wrapped by the pipeline into ‘Acta::ReplayHaltedByUpcaster`, which carries the offending record.
92 93 94 |
# File 'lib/acta/upcaster.rb', line 92 def fail_replay!(reason) raise FailReplay, reason end |
#key?(key) ⇒ Boolean
86 87 88 |
# File 'lib/acta/upcaster.rb', line 86 def key?(key) @store.key?(key) end |