Class: 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`.
Constant Summary
Constants included from Shared::OpenAPIFormat
Shared::OpenAPIFormat::OPENAPI_INTEGER_FORMATS, Shared::OpenAPIFormat::OPENAPI_NUMBER_FORMATS, Shared::OpenAPIFormat::OPENAPI_STRING_FORMATS
Constants included from Shared::OpenAPIType
Shared::OpenAPIType::OPENAPI_TYPES
Instance Attribute Summary
Attributes included from Shared::ItemType
Attributes inherited from BaseType
Attributes included from Shared::AdditionalProperties
Attributes included from Shared::Deprecation
Class Method Summary collapse
Instance Method Summary collapse
Methods included from Shared::ItemType
Methods included from Shared::AdditionalProperties
#additional_properties?, #inherited
Methods included from Shared::DerivedTypes
#define_derived_type, #derived_types, map
Methods included from Shared::Description
Methods included from Shared::Equivalence
#equal_properties?, #equivalent?
Methods included from Shared::Name
Methods included from Shared::OpenAPIFormat
#inherited, #openapi_format, #openapi_format=
Methods included from Shared::OpenAPIName
#default_openapi_name, #openapi_name, #openapi_name=
Methods included from Shared::OpenAPIType
#inherited, #openapi_type, #openapi_type=
Methods included from Shared::Rendering
#last_render, #last_render=, #render, #used_in_response
Methods included from Shared::TypeClass
Methods included from Shared::Errors
#coerce_error_message, #input_error, #response_error
Methods included from Shared::Caching
#cached_coerce_response, included
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).cached_coerce_response } end |