1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
# frozen_string_literal: true
require 'dry/types/array/member'
require 'dry/types/array/constructor'
module Dry
module Types
# Array type can be used to define an array with optional member type
#
# @api public
class Array < Nominal
# Build an array type with a member type
#
# @param [Type,#call] type
#
# @return [Array::Member]
#
# @api public
def of(type)
member =
case type
when String then Types[type]
else type
end
Array::Member.new(primitive, **options, member: member)
end
# @api private
def constructor_type
::Dry::Types::Array::Constructor
end
end
end
end
|