Class: LogStash::Setting::Integer
- Inherits:
-
Coercible
- Object
- LogStash::Setting
- Coercible
- LogStash::Setting::Integer
- Defined in:
- lib/logstash/settings.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from LogStash::Setting
Instance Method Summary collapse
- #coerce(value) ⇒ Object
-
#initialize(name, default = nil, strict = true) ⇒ Integer
constructor
A new instance of Integer.
Methods inherited from Coercible
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) ⇒ Integer
Returns a new instance of Integer.
307 308 309 |
# File 'lib/logstash/settings.rb', line 307 def initialize(name, default=nil, strict=true) super(name, ::Integer, default, strict) end |
Instance Method Details
#coerce(value) ⇒ Object
311 312 313 314 315 316 317 318 319 320 321 |
# File 'lib/logstash/settings.rb', line 311 def coerce(value) return value unless value.is_a?(::String) coerced_value = Integer(value) rescue nil if coerced_value.nil? raise ArgumentError.new("Failed to coerce value to Integer. Received #{value} (#{value.class})") else coerced_value end end |