Method: Datadog::Tracing::Contrib::Propagation::SqlComment::Comment#to_s

Defined in:
lib/datadog/tracing/contrib/propagation/sql_comment/comment.rb

#to_sObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/datadog/tracing/contrib/propagation/sql_comment/comment.rb', line 16

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