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

Methods included from Util::Loggable

included, #logger, #slow_logger

Constructor Details

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

Returns a new instance of String.



378
379
380
381
# File 'lib/logstash/settings.rb', line 378

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



383
384
385
386
387
388
# File 'lib/logstash/settings.rb', line 383

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