Class: Fusuma::Plugin::Base
- Inherits:
-
Object
- Object
- Fusuma::Plugin::Base
- Includes:
- CustomProcess
- Defined in:
- lib/fusuma/plugin/base.rb
Overview
Create a Plugin Class with extending this class
Direct Known Subclasses
Fusuma::Plugin::Buffers::Buffer, Detectors::Detector, Events::Event, Events::Records::Record, Executors::Executor, Filters::Filter, Inputs::Input, Parsers::Parser
Class Method Summary collapse
-
.inherited(subclass) ⇒ Object
when inherited from subclass.
-
.plugins ⇒ Array<Class>
get subclasses.
Instance Method Summary collapse
- #config_index ⇒ Object
-
#config_param_types ⇒ Hash
config parameter name and Type of the value of parameter.
- #config_params(key = nil, base: config_index) ⇒ Object
Methods included from CustomProcess
Class Method Details
Instance Method Details
#config_index ⇒ Object
54 55 56 |
# File 'lib/fusuma/plugin/base.rb', line 54 def config_index Config::Index.new(self.class.name.gsub('Fusuma::', '').underscore.split('/')) end |
#config_param_types ⇒ Hash
config parameter name and Type of the value of parameter
27 28 29 |
# File 'lib/fusuma/plugin/base.rb', line 27 def config_param_types raise NotImplementedError, "override #{self.class.name}##{__method__}" end |
#config_params(key = nil, base: config_index) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/fusuma/plugin/base.rb', line 32 def config_params(key = nil, base: config_index) params = Config.search(base) || {} return params unless key @config_params ||= {} @config_params["#{base.cache_key},#{key}"] ||= params.fetch(key, nil).tap do |val| next if val.nil? # NOTE: Type checking for config.yml param_types = Array(config_param_types.fetch(key)) next if param_types.any? { |klass| val.is_a?(klass) } MultiLogger.error('Please fix config.yml.') MultiLogger.error(":#{base.keys.map(&:symbol) .join(' => :')} => :#{key} should be #{param_types.join(' OR ')}.") exit 1 end end |