Sha256: 15e476e6443ab2939e85cc9a767cbe0467dd29c14fe0e6c13aa6b79e499c8b5d
Contents?: true
Size: 1011 Bytes
Versions: 12
Compression:
Stored size: 1011 Bytes
Contents
# Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details. # frozen_string_literal: true cs__scoped_require 'contrast/utils/duck_utils' module Contrast module Utils # This utility allows us to act on frozen objects, creating an unfrozen # duplicate in those cases where that is possible. class FreezeUtil class << self # Make every attempt to duplicate the frozen object so that it can # be tracked. # # @param original [Object] something frozen, usually a String # @return [Object] the original or an unfrozen copy def unfreeze_dup original return original unless original.cs__frozen? copy = original.dup if Contrast::Utils::DuckUtils.iterable_hash?(copy) copy.each_key do |key| value = original[key] copy[key] = value.dup end end copy end end end end end
Version data entries
12 entries across 12 versions & 1 rubygems