Class: Confium::Audit::MemorySink

Inherits:
Sink
  • Object
show all
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

Instance Method Summary collapse

Methods inherited from Sink

#call, #close

Constructor Details

#initializeMemorySink

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

#recordsObject (readonly)

Returns the value of attribute records.



68
69
70
# File 'lib/confium/audit.rb', line 68

def records
  @records
end

Instance Method Details

#clearObject



80
81
82
# File 'lib/confium/audit.rb', line 80

def clear
  @records.clear
end

#eachObject

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