Class: Fluent::RecordMapFilter

Inherits:
Filter
  • Object
show all
Defined in:
lib/fluent/plugin/filter_record_map.rb

Defined Under Namespace

Classes: Context

Constant Summary collapse

PARAM_INDICES =
1..9

Instance Method Summary collapse

Instance Method Details

#configure(conf) ⇒ Object

Context



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/fluent/plugin/filter_record_map.rb', line 24

def configure(conf)
  super
  @context = Context.new
  @maps = []
  @hostname = Socket.gethostname

  PARAM_INDICES.each do |i|
    expr = instance_variable_get("@map#{i}")
    @maps << expr if expr
  end
end

#filter(tag, time, record) ⇒ Object



36
37
38
39
40
41
42
43
44
# File 'lib/fluent/plugin/filter_record_map.rb', line 36

def filter(tag, time, record)
  bind = @context.context(tag, time, record, @hostname)

  @maps.each do |expr|
    eval(expr, bind)
  end

  eval('new_record', bind)
end