Class: LogStash::Setting::String

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

Direct Known Subclasses

NullableString

Instance Attribute Summary

Attributes inherited from LogStash::Setting

#default, #name

Instance Method Summary collapse

Methods inherited from LogStash::Setting

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

Constructor Details

#initialize(name, default = nil, strict = true, possible_strings = []) ⇒ String

Returns a new instance of String.



405
406
407
408
# File 'lib/logstash/settings.rb', line 405

def initialize(name, default=nil, strict=true, possible_strings=[])
  @possible_strings = possible_strings
  super(name, ::String, default, strict)
end

Instance Method Details

#validate(value) ⇒ Object



410
411
412
413
414
415
# File 'lib/logstash/settings.rb', line 410

def validate(value)
  super(value)
  unless @possible_strings.empty? || @possible_strings.include?(value)
    raise ArgumentError.new("Invalid value \"#{value}\". Options are: #{@possible_strings.inspect}")
  end
end