Class: Plumbing::Pipe::Filter

Inherits:
CustomFilter show all
Defined in:
lib/plumbing/pipe/filter.rb

Overview

A pipe that filters events from a source pipe

Instance Method Summary collapse

Methods inherited from Plumbing::Pipe

#add_observer, #is_observer?, #notify, #remove_observer, #shutdown

Methods included from Actor

#in_context?, included, #safely, #stop, timeout, transporter

Constructor Details

#initialize(source:) {|Plumbing::Event| ... } ⇒ Filter

Chain this pipe to the source pipe

Parameters:

  • source (Plumbing::Observable)

    the source from which to receive and filter events

  • &accepts (Block)

    a block that returns a boolean value - true to accept the event, false to reject it

Yields:

  • (Plumbing::Event)

    event the event that is currently being processed

Yield Returns:

  • (Boolean)

    true to accept the event, false to reject it



10
11
12
13
# File 'lib/plumbing/pipe/filter.rb', line 10

def initialize source:, &accepts
  super(source: source)
  @accepts = accepts.as(Callable)
end