Parent

Class/Module Index [+]

Quicksearch

Fluent::RecordTransformerFilter::RubyPlaceholderExpander

Attributes

log[R]
placeholders[R]

Public Class Methods

new(log) click to toggle source
# File lib/fluent/plugin/filter_record_transformer.rb, line 192
def initialize(log)
  @log = log
end

Public Instance Methods

expand(str) click to toggle source
# File lib/fluent/plugin/filter_record_transformer.rb, line 208
def expand(str)
  interpolated = str.gsub(/\$\{([^}]+)\}/, '#{\1}') # ${..} => #{..} 
  eval "\"#{interpolated}\"", @placeholders.instance_eval { binding }
rescue => e
  log.warn "failed to expand `#{str}`", :error_class => e.class, :error => e.message
  log.warn_backtrace
  nil
end
prepare_placeholders(time, record, opts) click to toggle source

Get placeholders as a struct

@param [Time] time the time @param [Hash] record the record @param [Hash] opts others

# File lib/fluent/plugin/filter_record_transformer.rb, line 201
def prepare_placeholders(time, record, opts)
  struct = UndefOpenStruct.new(record)
  struct.time = Time.at(time)
  opts.each {|key, value| struct.__send__("#{key}=", value) }
  @placeholders = struct
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.