Class: Diva::Type::ArrayType
Instance Attribute Summary
Attributes inherited from MetaType
Instance Method Summary collapse
- #cast(value) ⇒ Object
- #dump_for_json(value) ⇒ Object
-
#initialize(type) ⇒ ArrayType
constructor
A new instance of ArrayType.
- #to_s ⇒ Object
Methods inherited from MetaType
Constructor Details
Instance Method Details
#cast(value) ⇒ Object
180 181 182 183 |
# File 'lib/diva/type.rb', line 180 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 |
#dump_for_json(value) ⇒ Object
185 186 187 |
# File 'lib/diva/type.rb', line 185 def dump_for_json(value) value.to_a.map(&@type.method(:dump_for_json)) end |
#to_s ⇒ Object
189 190 191 |
# File 'lib/diva/type.rb', line 189 def to_s "Array of #{@type.to_s}" end |