Class: Fusuma::Plugin::Parsers::Parser
- Defined in:
- lib/fusuma/plugin/parsers/parser.rb
Overview
Parser change record and tag in event Inherite this base class
Direct Known Subclasses
Instance Method Summary collapse
-
#parse(event) ⇒ Event
Parse Event and convert Record and Tag if ‘#parse_record` return nil, this method will return original event.
-
#parse_record(_record) ⇒ Record?
parse Record object.
-
#source ⇒ Object
Set source for tag from config.yml.
- #tag ⇒ Object
Methods inherited from Base
#config_index, #config_param_types, #config_params, inherited, plugins
Instance Method Details
#parse(event) ⇒ Event
Parse Event and convert Record and Tag if ‘#parse_record` return nil, this method will return original event
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/fusuma/plugin/parsers/parser.rb', line 15 def parse(event) event.tap do |e| next if e.tag != source new_record = parse_record(e.record) next unless new_record e.record = new_record e.tag = tag end end |
#parse_record(_record) ⇒ Record?
parse Record object
40 41 42 |
# File 'lib/fusuma/plugin/parsers/parser.rb', line 40 def parse_record(_record) nil end |
#source ⇒ Object
Set source for tag from config.yml. DEFAULT_SOURCE is defined in each Parser plugins.
29 30 31 |
# File 'lib/fusuma/plugin/parsers/parser.rb', line 29 def source @source ||= config_params(:source) || self.class.const_get('DEFAULT_SOURCE') end |
#tag ⇒ Object
33 34 35 |
# File 'lib/fusuma/plugin/parsers/parser.rb', line 33 def tag self.class.name.split('::').last.underscore end |