Sha256: fcf44bd24a15f0d40ba54833fa430ba26970d9b02cd956959cc704e8e7514432
Contents?: true
Size: 530 Bytes
Versions: 5
Compression:
Stored size: 530 Bytes
Contents
# # Looks at the `:type` option and counts how many nested arrays # it contains around either nil or a callable value. # # The counted number is preserved in the `:wrap` virtual option # used by the [WrapType] dispatcher. # module Dry::Initializer::Dispatchers::UnwrapType extend self def call(type: nil, wrap: 0, **options) type, wrap = unwrap(type, 0) { type: type, wrap: wrap, **options } end private def unwrap(type, count) type.is_a?(Array) ? unwrap(type.first, count + 1) : [type, count] end end
Version data entries
5 entries across 5 versions & 1 rubygems