Class: MicrosoftKiotaAbstractions::SerializationWriterFactoryRegistry

Inherits:
Object
  • Object
show all
Includes:
SerializationWriterFactory
Defined in:
lib/microsoft_kiota_abstractions/serialization/serialization_writer_factory_registry.rb

Class Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.default_instanceObject

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_factoriesObject



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_instanceObject



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