Sha256: 98fb9c0f3a819f23f12bc5b03a51768fb5d7e541331da30032d2a411641b7e9b
Contents?: true
Size: 724 Bytes
Versions: 2
Compression:
Stored size: 724 Bytes
Contents
# frozen_string_literal: true # 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 module Initializer module Dispatchers module UnwrapType extend self def call(type: nil, wrap: 0, **options) type, count = unwrap(type, wrap) {type: type, wrap: count, **options} end private def unwrap(type, count) if type.is_a?(::Array) unwrap(type.first, count + 1) else [type, count] end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dry-initializer-3.1.1 | lib/dry/initializer/dispatchers/unwrap_type.rb |
dry-initializer-3.1.0 | lib/dry/initializer/dispatchers/unwrap_type.rb |