Class: Fusuma::Plugin::Base
- Inherits:
-
Object
- Object
- Fusuma::Plugin::Base
- 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) ⇒ Object
- #shutdown ⇒ Object abstract
Class Method Details
Instance Method Details
#config_index ⇒ Object
62 63 64 |
# File 'lib/fusuma/plugin/base.rb', line 62 def config_index @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
30 31 32 |
# File 'lib/fusuma/plugin/base.rb', line 30 def config_param_types raise NotImplementedError, "override #{self.class.name}##{__method__}" end |
#config_params(key = nil) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/fusuma/plugin/base.rb', line 37 def config_params(key = nil) @config_params ||= {} if @config_params["#{config_index.cache_key},#{key}"] return @config_params["#{config_index.cache_key},#{key}"] end params = Config.instance.fetch_config_params(key, config_index) return params unless key @config_params["#{config_index.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("`#{config_index.keys.join(".")}.#{key}` should be #{param_types.join(" OR ")}.") exit 1 end end |
#shutdown ⇒ Object
This method is abstract.
override ‘#shutdown` to implement
25 26 |
# File 'lib/fusuma/plugin/base.rb', line 25 def shutdown end |