Class: Kernai::Recorder::Sink::CompositeSink
- Defined in:
- lib/kernai/recorder.rb
Overview
Fan-out sink: forwards every entry to each child in declaration order. Entry queries are delegated to the first child, which is why MemorySink should usually be declared first when mixing it with non-queryable persistence sinks.
Instance Attribute Summary collapse
-
#sinks ⇒ Object
readonly
Returns the value of attribute sinks.
Instance Method Summary collapse
- #clear! ⇒ Object
- #entries ⇒ Object
-
#initialize(*sinks) ⇒ CompositeSink
constructor
A new instance of CompositeSink.
- #record(entry) ⇒ Object
Constructor Details
#initialize(*sinks) ⇒ CompositeSink
Returns a new instance of CompositeSink.
66 67 68 69 70 71 |
# File 'lib/kernai/recorder.rb', line 66 def initialize(*sinks) super() raise ArgumentError, 'CompositeSink needs at least one child sink' if sinks.empty? @sinks = sinks end |
Instance Attribute Details
#sinks ⇒ Object (readonly)
Returns the value of attribute sinks.
64 65 66 |
# File 'lib/kernai/recorder.rb', line 64 def sinks @sinks end |
Instance Method Details
#clear! ⇒ Object
81 82 83 |
# File 'lib/kernai/recorder.rb', line 81 def clear! @sinks.each(&:clear!) end |
#entries ⇒ Object
77 78 79 |
# File 'lib/kernai/recorder.rb', line 77 def entries @sinks.first.entries end |
#record(entry) ⇒ Object
73 74 75 |
# File 'lib/kernai/recorder.rb', line 73 def record(entry) @sinks.each { |sink| sink.record(entry) } end |