Class: MicrosoftKiotaAbstractions::ParseNodeFactoryRegistry
- Inherits:
-
Object
- Object
- MicrosoftKiotaAbstractions::ParseNodeFactoryRegistry
- Includes:
- ParseNodeFactory
- Defined in:
- lib/microsoft_kiota_abstractions/serialization/parse_node_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_parse_node(content_type, content) ⇒ Object
Methods included from ParseNodeFactory
Class Attribute Details
.default_instance ⇒ Object
Returns the value of attribute default_instance.
8 9 10 |
# File 'lib/microsoft_kiota_abstractions/serialization/parse_node_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/parse_node_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/parse_node_factory_registry.rb', line 12 def default_instance self.class.default_instance end |
#get_parse_node(content_type, content) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/microsoft_kiota_abstractions/serialization/parse_node_factory_registry.rb', line 20 def get_parse_node(content_type, content) if !content_type raise Exception.new 'content type cannot be undefined or empty' end if !content raise Exception.new 'content 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_parse_node(vendor_specific_content_type, content) end clean_content_type = vendor_specific_content_type.gsub(/[^\/]+\+/i, '') factory = @content_type_associated_factories[clean_content_type] if factory return factory.get_parse_node(clean_content_type, content) end raise Exception.new "Content type #{contentType} does not have a factory to be parsed" end |