Sha256: 775202f6d5ec5ca7ba0a8c4fcbb0dcd8402727691f41ed70c7ce05708980a546

Contents?: true

Size: 1013 Bytes

Versions: 3

Compression:

Stored size: 1013 Bytes

Contents

# frozen_string_literal: true

require "active_record/open_tracing/sql_sanitizer/base"
require "active_record/open_tracing/sql_sanitizer/mysql"
require "active_record/open_tracing/sql_sanitizer/postgres"
require "active_record/open_tracing/sql_sanitizer/sql_server"
require "active_record/open_tracing/sql_sanitizer/sqlite"
require "active_record/open_tracing/sql_sanitizer/regexes"

module ActiveRecord
  module OpenTracing
    module SqlSanitizer
      KLASSES = {
        mysql: Mysql,
        postgres: Postgres,
        sql_server: SqlServer,
        sqlite: Sqlite
      }.freeze

      class << self
        def build_sanitizer(sanitizer_name)
          sanitizer_klass(sanitizer_name).build
        end

        private

        def sanitizer_klass(sanitizer_name)
          key = KLASSES.keys.detect do |name|
            sanitizer_name.to_sym == name
          end || (raise NameError, "Unknown sanitizer #{sanitizer_name.inspect}")

          KLASSES.fetch(key)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
activerecord-instrumentation-0.4.0.jlauer3 lib/active_record/open_tracing/sql_sanitizer.rb
activerecord-instrumentation-0.4.0.jlauer2 lib/active_record/open_tracing/sql_sanitizer.rb
activerecord-instrumentation-0.4.0.jlauer1 lib/active_record/open_tracing/sql_sanitizer.rb