Class: LogStash::KeyNode
- Inherits:
-
Object
- Object
- LogStash::KeyNode
- Defined in:
- lib/logstash/string_interpolation.rb
Instance Method Summary collapse
- #evaluate(event) ⇒ Object
-
#initialize(key) ⇒ KeyNode
constructor
A new instance of KeyNode.
Constructor Details
#initialize(key) ⇒ KeyNode
Returns a new instance of KeyNode.
113 114 115 |
# File 'lib/logstash/string_interpolation.rb', line 113 def initialize(key) @key = key end |
Instance Method Details
#evaluate(event) ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/logstash/string_interpolation.rb', line 117 def evaluate(event) value = event[@key] case value when nil "%{#{@key}}" when Array value.join(",") when Hash LogStash::Json.dump(value) when Numeric value when TrueClass value when FalseClass value else # If we dont know how to deal with the type we return a string # to make sure we don't return a reference. "#{value}" end end |