Sha256: afb566a669bf14d3ab023a2619a05590f838cc477937e9de43c189b1373e133f

Contents?: true

Size: 776 Bytes

Versions: 5

Compression:

Stored size: 776 Bytes

Contents

# frozen_string_literal: true

module Datadog
  module Core
    module Utils
      # Refinements for {Hash}.
      module Hash
        # This refinement ensures modern rubies are allowed to use newer,
        # simpler, and more performant APIs.
        module Refinement
          # Introduced in Ruby 2.4
          unless ::Hash.method_defined?(:compact)
            refine ::Hash do
              def compact
                reject { |_k, v| v.nil? }
              end
            end
          end

          # Introduced in Ruby 2.4
          unless ::Hash.method_defined?(:compact!)
            refine ::Hash do
              def compact!
                reject! { |_k, v| v.nil? }
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ddtrace-1.12.1 lib/datadog/core/utils/hash.rb
ddtrace-1.12.0 lib/datadog/core/utils/hash.rb
ddtrace-1.11.1 lib/datadog/core/utils/hash.rb
ddtrace-1.11.0 lib/datadog/core/utils/hash.rb
ddtrace-1.11.0.beta1 lib/datadog/core/utils/hash.rb