Class: Diva::Type::ArrayType
Instance Attribute Summary
Attributes inherited from MetaType
Instance Method Summary collapse
- #cast(value) ⇒ Object
-
#initialize(type) ⇒ ArrayType
constructor
A new instance of ArrayType.
- #to_s ⇒ Object
Methods inherited from MetaType
Constructor Details
#initialize(type) ⇒ ArrayType
Returns a new instance of ArrayType.
157 158 159 160 161 |
# File 'lib/diva/type.rb', line 157 def initialize(type) type = Diva::Type(type) super("#{type.name}_array") @type = type end |
Instance Method Details
#cast(value) ⇒ Object
163 164 165 166 |
# File 'lib/diva/type.rb', line 163 def cast(value) raise Diva::InvalidTypeError, "The value is not a `#{name}'." unless value.is_a?(Enumerable) value.to_a.map(&@type.method(:cast)) end |
#to_s ⇒ Object
168 169 170 |
# File 'lib/diva/type.rb', line 168 def to_s "Array of #{type.to_s}" end |