Class: Taro::Types::ListType
- Inherits:
-
BaseType
- Object
- BaseType
- Taro::Types::ListType
- Extended by:
- Shared::ItemType
- Defined in:
- lib/taro/types/list_type.rb
Overview
Abstract base class for List types (arrays in OpenAPI terms). Unlike other types, this one should not be manually inherited from, but is used indirectly via ‘array_of: SomeType`.
Instance Attribute Summary
Attributes included from Shared::ItemType
Class Method Summary collapse
Instance Method Summary collapse
Methods included from Shared::ItemType
Class Method Details
.default_openapi_name ⇒ Object
23 24 25 |
# File 'lib/taro/types/list_type.rb', line 23 def self.default_openapi_name "#{item_type.openapi_name}_List" end |
Instance Method Details
#coerce_input ⇒ Object
9 10 11 12 13 14 |
# File 'lib/taro/types/list_type.rb', line 9 def coerce_input object.instance_of?(Array) || input_error('must be an Array') item_type = self.class.item_type object.map { |el| item_type.new(el).coerce_input } end |
#coerce_response ⇒ Object
16 17 18 19 20 21 |
# File 'lib/taro/types/list_type.rb', line 16 def coerce_response object.respond_to?(:map) || response_error('must be an Enumerable') item_type = self.class.item_type object.map { |el| item_type.new(el).coerce_response } end |