Module: Hanami::Utils::Duplicable
- Defined in:
- gems/gems/hanami-utils-1.3.3/lib/hanami/utils/duplicable.rb,
gems/gems/hanami-utils-1.3.8/lib/hanami/utils/duplicable.rb
Overview
Safe dup logic
Class Method Summary collapse
-
.dup(value, &blk) ⇒ Object
Duplicates the given value.
Class Method Details
.dup(value, &blk) ⇒ Object
Duplicates the given value.
It accepts a block to customize the logic.
The following types aren’t duped:
-
NilClass
-
FalseClass
-
TrueClass
-
Symbol
-
Numeric
All the other types are duped via #dup
Source: | on GitHub
def self.dup(value, &blk) case value when NilClass, FalseClass, TrueClass, Symbol, Numeric value when v = blk&.call(value) v else value.dup end end |