Sha256: 5924e728a9d1b18dd9f8c5d5bbc0226f5571faa35801f43d3da5c4e29f1c32db

Contents?: true

Size: 536 Bytes

Versions: 16

Compression:

Stored size: 536 Bytes

Contents

# typed: false

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

16 entries across 16 versions & 1 rubygems

Version Path
ddtrace-1.9.0 lib/datadog/core/utils/safe_dup.rb
ddtrace-1.8.0 lib/datadog/core/utils/safe_dup.rb
ddtrace-1.7.0 lib/datadog/core/utils/safe_dup.rb
ddtrace-1.6.1 lib/datadog/core/utils/safe_dup.rb
ddtrace-1.6.0 lib/datadog/core/utils/safe_dup.rb
ddtrace-1.5.2 lib/datadog/core/utils/safe_dup.rb
ddtrace-1.5.1 lib/datadog/core/utils/safe_dup.rb
ddtrace-1.5.0 lib/datadog/core/utils/safe_dup.rb
ddtrace-1.4.2 lib/datadog/core/utils/safe_dup.rb
ddtrace-1.4.1 lib/datadog/core/utils/safe_dup.rb
ddtrace-1.4.0 lib/datadog/core/utils/safe_dup.rb
ddtrace-1.3.0 lib/datadog/core/utils/safe_dup.rb
ddtrace-1.2.0 lib/datadog/core/utils/safe_dup.rb
ddtrace-1.1.0 lib/datadog/core/utils/safe_dup.rb
ddtrace-1.0.0 lib/datadog/core/utils/safe_dup.rb
ddtrace-1.0.0.beta2 lib/datadog/core/utils/safe_dup.rb