Sha256: 5727aaf66bffabe0dae5b55fdd90504d629363e025b0c82abe6afdd4f75d7ac7

Contents?: true

Size: 847 Bytes

Versions: 5

Compression:

Stored size: 847 Bytes

Contents

# frozen_string_literal: true

# typed: false

require 'erb'

module Datadog
  module Tracing
    module Contrib
      module Propagation
        module SqlComment
          # To be prepended to a sql statement.
          class Comment
            def initialize(hash)
              @hash = hash
            end

            def to_s
              @string ||= begin
                ret = String.new

                @hash.each do |key, value|
                  next if value.nil?

                  # Url encode
                  value = ERB::Util.url_encode(value)

                  # Escape SQL
                  ret << "#{key}='#{value}',"
                end

                # Remove the last `,`
                ret.chop!

                "/*#{ret}*/"
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ddtrace-1.9.0 lib/datadog/tracing/contrib/propagation/sql_comment/comment.rb
ddtrace-1.8.0 lib/datadog/tracing/contrib/propagation/sql_comment/comment.rb
ddtrace-1.7.0 lib/datadog/tracing/contrib/propagation/sql_comment/comment.rb
ddtrace-1.6.1 lib/datadog/tracing/contrib/propagation/sql_comment/comment.rb
ddtrace-1.6.0 lib/datadog/tracing/contrib/propagation/sql_comment/comment.rb