Class: Dry::Data::Type::Array
- Inherits:
-
Dry::Data::Type
- Object
- Dry::Data::Type
- Dry::Data::Type::Array
- Defined in:
- lib/dry/data/type/array.rb
Instance Attribute Summary
Attributes inherited from Dry::Data::Type
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Dry::Data::Type
[], #call, #constrained, #enum, #initialize, #name, #optional, passthrough_constructor, strict_constructor, #valid?, #|
Constructor Details
This class inherits a constructor from Dry::Data::Type
Class Method Details
.constructor(array_constructor, member_constructor, input) ⇒ Object
5 6 7 |
# File 'lib/dry/data/type/array.rb', line 5 def self.constructor(array_constructor, member_constructor, input) array_constructor[input].map(&member_constructor) end |
Instance Method Details
#member(type) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/dry/data/type/array.rb', line 9 def member(type) member_constructor = case type when Type then type.constructor when Class then Data[type].constructor else raise ArgumentError, "+#{type}+ is an unsupported array member" end array_constructor = self.class .method(:constructor).to_proc.curry.(constructor, member_constructor) self.class.new(array_constructor, primitive) end |