Class: Confium::Audit::MemorySink
- Includes:
- Enumerable
- Defined in:
- lib/confium/audit.rb
Overview
In-memory sink. Records are collected in #records and inspected
in specs. Implements #clear for resetting between tests.
Includes Enumerable so callers can iterate, filter, and reduce over recorded events directly:
sink.select { |r| r["operation"] == "composite_sign" }
sink.count { |r| r["result"] == "failure" }
sink.find { |r| r["actor"] == "director-1" }
Instance Attribute Summary collapse
-
#records ⇒ Object
readonly
Returns the value of attribute records.
Instance Method Summary collapse
- #clear ⇒ Object
-
#each ⇒ Object
Enumerable contract: yield each record in insertion order.
-
#initialize ⇒ MemorySink
constructor
A new instance of MemorySink.
- #write(record) ⇒ Object
Methods inherited from Sink
Constructor Details
#initialize ⇒ MemorySink
Returns a new instance of MemorySink.
70 71 72 73 |
# File 'lib/confium/audit.rb', line 70 def initialize # @type ivar @records: Array[untyped] @records = [] end |
Instance Attribute Details
#records ⇒ Object (readonly)
Returns the value of attribute records.
68 69 70 |
# File 'lib/confium/audit.rb', line 68 def records @records end |
Instance Method Details
#clear ⇒ Object
80 81 82 |
# File 'lib/confium/audit.rb', line 80 def clear @records.clear end |
#each ⇒ Object
Enumerable contract: yield each record in insertion order.
85 86 87 |
# File 'lib/confium/audit.rb', line 85 def each(&) @records.each(&) end |
#write(record) ⇒ Object
75 76 77 78 |
# File 'lib/confium/audit.rb', line 75 def write(record) @records << record self end |