Sha256: 036d9d024b738e572ce7757c13b7715f8fb511f89cee4d8ede7f9532f4b018d4

Contents?: true

Size: 896 Bytes

Versions: 46

Compression:

Stored size: 896 Bytes

Contents

# encoding: utf-8
module LogStash module Filters module Jdbc
  class Validatable
    def self.find_validation_errors(options)
      array_of_options = Array(options)
      errors = []
      array_of_options.each do |options|
        instance = new(options)
        unless instance.valid?
          errors << instance.formatted_errors
        end
      end
      return nil if errors.empty?
      errors.join("; ")
    end

    def initialize(options)
      pre_initialize(options)
      @options = options
      @valid = false
      @option_errors = []
      parse_options
      post_initialize
    end

    def valid?
      @valid
    end

    def formatted_errors
      @option_errors.join(", ")
    end

    private

    def pre_initialize(options)
    end

    def post_initialize
    end

    def parse_options
      raise "Subclass must implement 'parse_options'"
    end
  end
end end end

Version data entries

46 entries across 46 versions & 2 rubygems

Version Path
logstash-integration-jdbc-5.5.1 lib/logstash/filters/jdbc/validatable.rb
logstash-integration-jdbc-5.5.0 lib/logstash/filters/jdbc/validatable.rb
logstash-integration-jdbc-5.4.9 lib/logstash/filters/jdbc/validatable.rb
logstash-integration-jdbc-5.4.8 lib/logstash/filters/jdbc/validatable.rb
logstash-integration-jdbc-5.4.7 lib/logstash/filters/jdbc/validatable.rb
logstash-integration-jdbc-5.4.6 lib/logstash/filters/jdbc/validatable.rb
logstash-integration-jdbc-5.4.5 lib/logstash/filters/jdbc/validatable.rb
logstash-integration-jdbc-5.4.4 lib/logstash/filters/jdbc/validatable.rb
logstash-integration-jdbc-5.4.3 lib/logstash/filters/jdbc/validatable.rb
logstash-integration-jdbc-5.4.2 lib/logstash/filters/jdbc/validatable.rb
logstash-integration-jdbc-5.4.1 lib/logstash/filters/jdbc/validatable.rb
logstash-integration-jdbc-5.4.0 lib/logstash/filters/jdbc/validatable.rb
logstash-integration-jdbc-5.3.0 lib/logstash/filters/jdbc/validatable.rb
logstash-integration-jdbc-5.2.6 lib/logstash/filters/jdbc/validatable.rb
logstash-integration-jdbc-5.2.5 lib/logstash/filters/jdbc/validatable.rb
logstash-integration-jdbc-5.2.4 lib/logstash/filters/jdbc/validatable.rb
logstash-integration-jdbc-5.2.3 lib/logstash/filters/jdbc/validatable.rb
logstash-integration-jdbc-5.2.2 lib/logstash/filters/jdbc/validatable.rb
logstash-integration-jdbc-5.2.1 lib/logstash/filters/jdbc/validatable.rb
logstash-integration-jdbc-5.2.0 lib/logstash/filters/jdbc/validatable.rb