Class: LogStash::Setting::SplittableStringArray

Inherits:
ArrayCoercible show all
Defined in:
lib/logstash/settings.rb

Constant Summary collapse

DEFAULT_TOKEN =
","

Instance Attribute Summary

Attributes inherited from LogStash::Setting

#default, #name

Instance Method Summary collapse

Methods inherited from Coercible

#set

Methods inherited from LogStash::Setting

#==, #reset, #set, #set?, #strict?, #to_hash, #validate_value, #value

Constructor Details

#initialize(name, klass, default, strict = true, tokenizer = DEFAULT_TOKEN, &validator_proc) ⇒ SplittableStringArray

Returns a new instance of SplittableStringArray.



549
550
551
552
553
# File 'lib/logstash/settings.rb', line 549

def initialize(name, klass, default, strict=true, tokenizer = DEFAULT_TOKEN, &validator_proc)
  @element_class = klass
  @token = tokenizer
  super(name, klass, default, strict, &validator_proc)
end

Instance Method Details

#coerce(value) ⇒ Object



555
556
557
558
559
560
561
562
563
# File 'lib/logstash/settings.rb', line 555

def coerce(value)
  if value.is_a?(Array)
    value
  elsif value.nil?
    []
  else
    value.split(@token).map(&:strip)
  end
end