Class: Dry::Types::Array

Inherits:
Nominal show all
Defined in:
lib/dry/types/array.rb,
lib/dry/types/array/member.rb,
lib/dry/types/array/constructor.rb

Direct Known Subclasses

Member

Defined Under Namespace

Classes: Constructor, Member

Constant Summary

Constants inherited from Nominal

Nominal::ALWAYS

Instance Attribute Summary

Attributes inherited from Nominal

#primitive

Attributes included from Options

#options

Instance Method Summary collapse

Methods inherited from Nominal

[], #call_safe, #call_unsafe, #coerce, #constrained?, #default?, #failure, #initialize, #lax, #name, #optional?, #primitive?, #success, #to_ast, #to_proc, #try, #try_coerce

Methods included from Printable

#to_s

Methods included from Builder

#&, #>, #constrained, #constrained_type, #constructor, #default, #enum, #fallback, #lax, #maybe, #optional, #|

Methods included from Meta

#initialize, #meta, #pristine, #with

Methods included from Options

#initialize, #with

Methods included from Type

#call, #valid?

Constructor Details

This class inherits a constructor from Dry::Types::Nominal

Instance Method Details

#constructor_typeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



27
28
29
# File 'lib/dry/types/array.rb', line 27

def constructor_type
  ::Dry::Types::Array::Constructor
end

#of(type) ⇒ Array::Member

Build an array type with a member type

Parameters:

Returns:



16
17
18
19
20
21
22
23
24
# File 'lib/dry/types/array.rb', line 16

def of(type)
  member =
    case type
    when String then Types[type]
    else type
    end

  Array::Member.new(primitive, **options, member: member)
end