Class: MicrosoftKiotaAbstractions::SerializationWriterFactoryRegistry
- Inherits:
-
Object
- Object
- MicrosoftKiotaAbstractions::SerializationWriterFactoryRegistry
- Includes:
- SerializationWriterFactory
- Defined in:
- lib/microsoft_kiota_abstractions/serialization/serialization_writer_factory_registry.rb
Class Attribute Summary collapse
-
.default_instance ⇒ Object
Returns the value of attribute default_instance.
Instance Method Summary collapse
- #content_type_associated_factories ⇒ Object
- #default_instance ⇒ Object
- #get_serialization_writer(content_type) ⇒ Object
Class Attribute Details
.default_instance ⇒ Object
Returns the value of attribute default_instance.
8 9 10 |
# File 'lib/microsoft_kiota_abstractions/serialization/serialization_writer_factory_registry.rb', line 8 def default_instance @default_instance end |
Instance Method Details
#content_type_associated_factories ⇒ Object
16 17 18 |
# File 'lib/microsoft_kiota_abstractions/serialization/serialization_writer_factory_registry.rb', line 16 def content_type_associated_factories @content_type_associated_factories ||= Hash.new end |
#default_instance ⇒ Object
12 13 14 |
# File 'lib/microsoft_kiota_abstractions/serialization/serialization_writer_factory_registry.rb', line 12 def default_instance self.class.default_instance end |
#get_serialization_writer(content_type) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/microsoft_kiota_abstractions/serialization/serialization_writer_factory_registry.rb', line 20 def get_serialization_writer(content_type) if !content_type raise Exception.new 'content type cannot be undefined or empty' end vendor_specific_content_type = content_type.split(';').first factory = @content_type_associated_factories[vendor_specific_content_type] if factory return factory.get_serialization_writer(vendor_specific_content_type) end clean_content_type = vendor_specific_content_type.gsub(/[^\/]+\+/i, '') factory = @content_type_associated_factories[clean_content_type] if factory return factory.get_serialization_writer(clean_content_type) end raise Exception.new "Content type #{contentType} does not have a factory to be serialized" end |