Sha256: ecd99b3502979d7cc29062af85dddb742b22c1e1adc45bb1363e3968baddeedd

Contents?: true

Size: 520 Bytes

Versions: 2

Compression:

Stored size: 520 Bytes

Contents

module Datadog
  module Core
    module Utils
      # Helper methods for safer dup
      module SafeDup
        if RUBY_VERSION < '2.2' # nil.dup only fails in Ruby 2.1
          # Ensures #initialize can call nil.dup safely
          module RefineNil
            refine NilClass do
              def dup
                self
              end
            end
          end

          using RefineNil
        end

        def self.frozen_or_dup(v)
          v.frozen? ? v : v.dup
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ddtrace-1.10.1 lib/datadog/core/utils/safe_dup.rb
ddtrace-1.10.0 lib/datadog/core/utils/safe_dup.rb