Module: TTY::Option::DeepDup Private
- Defined in:
- lib/tty/option/deep_dup.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Responsible for deep copying an object
Constant Summary collapse
- NONDUPLICATABLE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
[ Symbol, TrueClass, FalseClass, NilClass, Numeric, Method, UnboundMethod ].freeze
Class Method Summary collapse
-
.deep_dup(object, cache = {}) ⇒ Object
Deep copy an object.
Class Method Details
.deep_dup(object, cache = {}) ⇒ Object
Deep copy an object
26 27 28 29 30 31 32 33 34 |
# File 'lib/tty/option/deep_dup.rb', line 26 def self.deep_dup(object, cache = {}) cache[object.object_id] ||= case object when *NONDUPLICATABLE then object when Array then deep_dup_array(object, cache) when Hash then deep_dup_hash(object, cache) else object.dup end end |