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.



591
592
593
594
595
# File 'lib/logstash/settings.rb', line 591

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



597
598
599
600
601
602
603
604
605
# File 'lib/logstash/settings.rb', line 597

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