Class: Fusuma::Plugin::Filters::Filter

Inherits:
Base
  • Object
show all
Defined in:
lib/fusuma/plugin/filters/filter.rb

Overview

Filter to keep/discard events from input plugin

Direct Known Subclasses

LibinputDeviceFilter

Instance Method Summary collapse

Methods inherited from Base

#config_index, #config_param_types, #config_params, inherited, plugins, #shutdown

Instance Method Details

#filter(event) ⇒ Event, NilClass

Filter input event

Parameters:

  • event (Event)

Returns:

  • (Event)

    when keeping event

  • (NilClass)

    when discarding record



14
15
16
17
18
19
20
# File 'lib/fusuma/plugin/filters/filter.rb', line 14

def filter(event)
  return event if !/#{source}/.match?(event.tag)

  return event if keep?(event.record)

  nil
end

#keep?(record) ⇒ True, False

This method is abstract.

override ‘#keep?` to implement

Parameters:

Returns:

  • (True)

    when keeping record

  • (False)

    when discarding record



26
27
28
# File 'lib/fusuma/plugin/filters/filter.rb', line 26

def keep?(record)
  true if record
end

#sourceObject

Set source for tag from config.yml. DEFAULT_SOURCE is defined in each Filter plugins.



32
33
34
# File 'lib/fusuma/plugin/filters/filter.rb', line 32

def source
  @source ||= config_params(:source) || self.class.const_get(:DEFAULT_SOURCE)
end