Class: Turbine::Pipeline::JournalFilter
- Includes:
- Turbine::Pipeline::Journal::Read
- Defined in:
- lib/turbine/pipeline/journal_filter.rb
Overview
A filter which uses an upstream Journal as a basis for determining which values should be emitted.
Instance Attribute Summary
Attributes inherited from Segment
Instance Method Summary collapse
-
#initialize(mode, name) ⇒ JournalFilter
constructor
Public: Creates a new JournalFilter.
-
#source=(source) ⇒ Object
Public: Sets the previous segment in the pipeline.
-
#to_s ⇒ Object
Public: Describes the segments through which each input will pass.
Methods included from Turbine::Pipeline::Journal::Read
Methods inherited from Filter
Methods included from Trace::Transparent
Methods inherited from Segment
#append, #each, #inspect, #next, #rewind, #trace, #tracing=
Constructor Details
#initialize(mode, name) ⇒ JournalFilter
Public: Creates a new JournalFilter.
mode - The filter mode to be used. :only will cause the filter to emit
only values which were seen in the journal, while :except will
emit only those which were *not* seen.
name - The name of the Journal whose values will be used.
Returns a JournalFilter.
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/turbine/pipeline/journal_filter.rb', line 16 def initialize(mode, name) unless mode == :only || mode == :except raise ArgumentError, 'JournalFilter mode must be :only or :except' end @mode = mode @journal_name = name super(&method(:"filter_#{ mode }")) end |
Instance Method Details
#source=(source) ⇒ Object
Public: Sets the previous segment in the pipeline.
Raises NoSuchJournalError if the Journal required by the filter is not present in the source pipeline.
Returns the source.
33 34 35 36 |
# File 'lib/turbine/pipeline/journal_filter.rb', line 33 def source=(source) super @journal = journal(@journal_name) end |
#to_s ⇒ Object
Public: Describes the segments through which each input will pass.
Return a string.
41 42 43 |
# File 'lib/turbine/pipeline/journal_filter.rb', line 41 def to_s "#{ source_to_s } | #{ @mode }(#{ @journal_name.inspect })" end |