Class: LogStash::PluginMixins::JdbcStreaming::ParameterHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/plugin_mixins/jdbc_streaming/parameter_handler.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(given_value) ⇒ ParameterHandler

Returns a new instance of ParameterHandler.



38
39
40
# File 'lib/logstash/plugin_mixins/jdbc_streaming/parameter_handler.rb', line 38

def initialize(given_value)
  @given_value = given_value
end

Instance Attribute Details

#given_valueObject (readonly)

Returns the value of attribute given_value.



36
37
38
# File 'lib/logstash/plugin_mixins/jdbc_streaming/parameter_handler.rb', line 36

def given_value
  @given_value
end

Class Method Details

.build_bind_value_handler(given_value) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/logstash/plugin_mixins/jdbc_streaming/parameter_handler.rb', line 19

def self.build_bind_value_handler(given_value)
  handler = ConstantParameter.new(given_value)

  return handler unless given_value.is_a?(String) # allow non String constants

  first_percent_curly = given_value.index("%{")
  if first_percent_curly && given_value.index("}", first_percent_curly)
    return InterpolatedParameter.new(given_value)
  end

  if given_value =~ /\A(\s*\[[^\]]+\]\s*)*\z/
    return FieldParameter.new(given_value)
  end

  handler
end

.build_parameter_handler(given_value) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/logstash/plugin_mixins/jdbc_streaming/parameter_handler.rb', line 6

def self.build_parameter_handler(given_value)
  # does it really make sense to deal with normal parameters differently?
  handler = FieldParameter.new(given_value)
  return handler unless given_value.is_a?(String)

  first_percent_curly = given_value.index("%{")
  if first_percent_curly && given_value.index("}", first_percent_curly)
    return InterpolatedParameter.new(given_value)
  end

  handler
end

Instance Method Details

#extract_from(event) ⇒ Object



42
43
44
# File 'lib/logstash/plugin_mixins/jdbc_streaming/parameter_handler.rb', line 42

def extract_from(event)
  # override in subclass
end