Module: Fluent::Compat::TypeConverter

Included in:
Fluent::Compat::TextParser::ValuesParser
Defined in:
lib/fluent/compat/type_converter.rb

Constant Summary collapse

Converters =
{
  'string' => lambda { |v| v.to_s },
  'integer' => lambda { |v| v.to_i },
  'float' => lambda { |v| v.to_f },
  'bool' => lambda { |v|
    case v.downcase
    when 'true', 'yes', '1'
      true
    else
      false
    end
  },
  'time' => lambda { |v, time_parser|
    time_parser.parse(v)
  },
  'array' => lambda { |v, delimiter|
    v.to_s.split(delimiter)
  }
}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/fluent/compat/type_converter.rb', line 40

def self.included(klass)
  klass.instance_eval {
    config_param :types, :string, default: nil
    config_param :types_delimiter, :string, default: ','
    config_param :types_label_delimiter, :string, default: ':'
  }
end

Instance Method Details

#configure(conf) ⇒ Object



48
49
50
51
52
53
# File 'lib/fluent/compat/type_converter.rb', line 48

def configure(conf)
  super

  @type_converters = nil
  @type_converters = parse_types_parameter unless @types.nil?
end