module Dry::Initializer::Dispatchers::WrapType
Public Instance Methods
call(type: nil, wrap: 0, **options)
click to toggle source
# File lib/dry/initializer/dispatchers/wrap_type.rb, line 11 def call(type: nil, wrap: 0, **options) {type: wrapped_type(type, wrap), **options} end
Private Instance Methods
wrap_value(value, count, type)
click to toggle source
# File lib/dry/initializer/dispatchers/wrap_type.rb, line 23 def wrap_value(value, count, type) if count.zero? type ? type.call(value) : value else return [wrap_value(value, count - 1, type)] unless value.is_a?(Array) value.map { |item| wrap_value(item, count - 1, type) } end end
wrapped_type(type, count)
click to toggle source
# File lib/dry/initializer/dispatchers/wrap_type.rb, line 17 def wrapped_type(type, count) return type if count.zero? ->(value) { wrap_value(value, count, type) } end