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
# File 'lib/confium/audit.rb', line 70

def initialize
  @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



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