Module: LogStash::PluginMixins::Jdbc::ValueHandler

Included in:
Filters::Jdbc::Lookup, Jdbc, LogStash::PluginMixins::JdbcStreaming::StatementHandler
Defined in:
lib/logstash/plugin_mixins/jdbc/value_handler.rb

Overview

Provides functions to extract the row’s values, ensuring column types are properly decorated to become coercible to a LogStash::Event.

Instance Method Summary collapse

Instance Method Details

#decorate_value(value) ⇒ Object

Decorate the value so it can be used as a LogStash::Event field



15
16
17
18
19
20
21
22
# File 'lib/logstash/plugin_mixins/jdbc/value_handler.rb', line 15

def decorate_value(value)
  case value
  when Date, DateTime
    value.to_time
  else
    value
  end
end

#extract_values_from(row) ⇒ Object

Stringify the row keys and decorate values when necessary



10
11
12
# File 'lib/logstash/plugin_mixins/jdbc/value_handler.rb', line 10

def extract_values_from(row)
  Hash[row.map { |k, v| [k.to_s, decorate_value(v)] }]
end