Class: Replay::Backends::MemoryStore
- Inherits:
-
Object
- Object
- Replay::Backends::MemoryStore
- Includes:
- Singleton
- Defined in:
- lib/replay/backends.rb
Class Method Summary collapse
- .[](stream_id) ⇒ Object
- .clear ⇒ Object
- .event_stream(stream_id) ⇒ Object
- .published(envelope) ⇒ Object
Instance Method Summary collapse
- #clear ⇒ Object
- #event_stream(stream_id) ⇒ Object
-
#initialize ⇒ MemoryStore
constructor
A new instance of MemoryStore.
- #published(envelope) ⇒ Object
Constructor Details
#initialize ⇒ MemoryStore
Returns a new instance of MemoryStore.
15 16 17 |
# File 'lib/replay/backends.rb', line 15 def initialize @store = {} end |
Class Method Details
.[](stream_id) ⇒ Object
42 43 44 |
# File 'lib/replay/backends.rb', line 42 def self.[](stream_id) instance.event_stream(stream_id) end |
.clear ⇒ Object
22 23 24 |
# File 'lib/replay/backends.rb', line 22 def self.clear instance.clear end |
.event_stream(stream_id) ⇒ Object
39 40 41 |
# File 'lib/replay/backends.rb', line 39 def self.event_stream(stream_id) instance.event_stream(stream_id) end |
.published(envelope) ⇒ Object
18 19 20 |
# File 'lib/replay/backends.rb', line 18 def self.published(envelope) instance.published(envelope) end |
Instance Method Details
#clear ⇒ Object
26 27 28 |
# File 'lib/replay/backends.rb', line 26 def clear @store = {} end |
#event_stream(stream_id) ⇒ Object
35 36 37 |
# File 'lib/replay/backends.rb', line 35 def event_stream(stream_id) @store[stream_id] || [] end |
#published(envelope) ⇒ Object
30 31 32 33 |
# File 'lib/replay/backends.rb', line 30 def published(envelope) @store[stream_id] ||= [] @store[stream_id] << envelope end |