class Fluent::Plugin::ConfigExpanderOutput

Public Instance Methods

builtin_mapping() click to toggle source
# File lib/fluent/plugin/out_config_expander.rb, line 22
def builtin_mapping
  {'__hostname__' => @hostname, '__HOSTNAME__' => @hostname, '${hostname}' => @hostname, '${HOSTNAME}' => @hostname}
end
configure(conf) click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_config_expander.rb, line 33
def configure(conf)
  super

  ex = expand_config(@config_config.corresponding_config_element)
  type = ex['@type']
  @plugin = Fluent::Plugin.new_output(type)
  @plugin.context_router = self.event_emitter_router(conf['@label'])
  @plugin.configure(ex)
  mark_used(@config_config.corresponding_config_element)

  # hack for https://bugs.ruby-lang.org/issues/12478 in ruby 2.3 or earlier
  mojule = Module.new do
    def method_defined?(accessor)
      methods.include?(accessor.to_sym)
    end
    def private_method_defined?(accessor)
      private_methods.include?(accessor.to_sym)
    end
  end
  self.extend(mojule) unless self.class === Module

  self.extend SingleForwardable
  override_methods = @plugin.methods - SingleForwardable.instance_methods - Object.instance_methods
  def_delegators(:@plugin, *override_methods)
end
expand_config(conf) click to toggle source
# File lib/fluent/plugin/out_config_expander.rb, line 26
def expand_config(conf)
  ex = Fluent::Config::Expander.expand(conf, builtin_mapping())
  ex.name = 'match' # name/arg will be ignored by Plugin#configure, but anyway
  ex.arg = conf.arg
  ex
end
mark_used(conf) click to toggle source
# File lib/fluent/plugin/out_config_expander.rb, line 17
def mark_used(conf)
  conf.keys.each {|key| conf[key] } # to suppress unread configuration warning
  conf.elements.each{|e| mark_used(e)}
end
method_defined?(accessor) click to toggle source
# File lib/fluent/plugin/out_config_expander.rb, line 45
def method_defined?(accessor)
  methods.include?(accessor.to_sym)
end
private_method_defined?(accessor) click to toggle source
# File lib/fluent/plugin/out_config_expander.rb, line 48
def private_method_defined?(accessor)
  private_methods.include?(accessor.to_sym)
end