From 58646fa00b75afe5f292459a99c8476b11e6d452 Mon Sep 17 00:00:00 2001 From: Lande24 Date: Mon, 7 Sep 2015 00:00:44 +0300 Subject: [PATCH] Making valid_conversions an instance variable so that you can override it in class inheriting from Mutate --- lib/logstash/filters/mutate.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/logstash/filters/mutate.rb b/lib/logstash/filters/mutate.rb index d434290..8a1b01e 100644 --- a/lib/logstash/filters/mutate.rb +++ b/lib/logstash/filters/mutate.rb @@ -176,15 +176,18 @@ class LogStash::Filters::Mutate < LogStash::Filters::Base # } config :merge, :validate => :hash + def initialize + @valid_conversions = %w(string integer float boolean) + end + public def register - valid_conversions = %w(string integer float boolean) # TODO(sissel): Validate conversion requests if provided. @convert.nil? or @convert.each do |field, type| - if !valid_conversions.include?(type) + if !@valid_conversions.include?(type) raise LogStash::ConfigurationError, I18n.t("logstash.agent.configuration.invalid_plugin_register", :plugin => "filter", :type => "mutate", - :error => "Invalid conversion type '#{type}', expected one of '#{valid_conversions.join(',')}'") + :error => "Invalid conversion type '#{type}', expected one of '#{@valid_conversions.join(',')}'") end end # @convert.each