Class: Mayu::Utils::DeepDuper
- Inherits:
-
Object
- Object
- Mayu::Utils::DeepDuper
- Extended by:
- T::Generic, T::Sig
- Defined in:
- lib/mayu/utils.rb
Constant Summary collapse
- Elem =
type_member { { upper: Object } }
Instance Method Summary collapse
- #deep_dup ⇒ Object
-
#initialize(obj) ⇒ DeepDuper
constructor
A new instance of DeepDuper.
Constructor Details
#initialize(obj) ⇒ DeepDuper
Returns a new instance of DeepDuper.
75 |
# File 'lib/mayu/utils.rb', line 75 def initialize(obj) = @obj = obj |
Instance Method Details
#deep_dup ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/mayu/utils.rb', line 78 def deep_dup case @obj when Hash @obj.dup T.cast( @obj .transform_keys { Utils.deep_dup(_1) } .transform_values { Utils.deep_dup(_1) }, Elem ) when Array T.cast(@obj.map(&:dup), Elem) else @obj.dup end end |