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(&block) ⇒ 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 |
# File 'lib/confium/audit.rb', line 70 def initialize @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
79 80 81 |
# File 'lib/confium/audit.rb', line 79 def clear @records.clear end |
#each(&block) ⇒ Object
Enumerable contract: yield each record in insertion order.
84 85 86 |
# File 'lib/confium/audit.rb', line 84 def each(&block) @records.each(&block) end |
#write(record) ⇒ Object
74 75 76 77 |
# File 'lib/confium/audit.rb', line 74 def write(record) @records << record self end |