Module: Hanami::Utils::Duplicable
- Defined in:
- 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:
* <tt>NilClass</tt>
* <tt>FalseClass</tt>
* <tt>TrueClass</tt>
* <tt>Symbol</tt>
* <tt>Numeric</tt>
All the other types are duped via #dup
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/hanami/utils/duplicable.rb', line 70 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 |