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, #shutdown
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 |
# File 'lib/fusuma/plugin/parsers/parser.rb', line 15 def parse(event) return event if event.tag != source new_record = parse_record(event.record) return event if new_record.nil? event.record = new_record event.tag = tag event end |
#parse_record(_record) ⇒ Record?
parse Record object
39 40 41 |
# File 'lib/fusuma/plugin/parsers/parser.rb', line 39 def parse_record(_record) nil end |
#source ⇒ Object
Set source for tag from config.yml. DEFAULT_SOURCE is defined in each Parser plugins.
28 29 30 |
# File 'lib/fusuma/plugin/parsers/parser.rb', line 28 def source @source ||= config_params(:source) || self.class.const_get(:DEFAULT_SOURCE) end |
#tag ⇒ Object
32 33 34 |
# File 'lib/fusuma/plugin/parsers/parser.rb', line 32 def tag @tag ||= self.class.name.split("::").last.underscore end |