# Module LittleGhost::ExecutionState

Documentation version: Edge

Canonical HTML: https://littleghostai.org/docs/LittleGhost/ExecutionState.html

ExecutionState carries request-scoped values across scheduled fibers and
worker threads. It keeps event and instrumentation context from leaking
between concurrent runs.

Framework extensions may use #capture and #with to preserve event and
instrumentation context. Captured hashes are immutable; values within them are
not deep-copied.

## Class methods

<a id="method-c-5B-5D"></a>
### `.[]`

```ruby
.[](key)
```

Reads `key` from the current execution state.

<a id="method-c-5B-5D-3D"></a>
### `.[]=`

```ruby
.[]=(key, value)
```

Replaces `key` in the current fiber-local state.

<a id="method-c-capture"></a>
### `.capture`

```ruby
.capture()
```

Captures the current immutable state hash for propagation.

<a id="method-c-delete"></a>
### `.delete`

```ruby
.delete(key)
```

Deletes `key` and returns its previous value.

<a id="method-c-with"></a>
### `.with`

```ruby
.with(values)
```

Merges `values` while the block runs, then restores prior state.
