Class: Lutaml::Model::FormatRegistry
- Inherits:
-
Object
- Object
- Lutaml::Model::FormatRegistry
- Defined in:
- lib/lutaml/model/format_registry.rb
Class Attribute Summary collapse
-
.adapter_class ⇒ Object
readonly
Returns the value of attribute adapter_class.
-
.format ⇒ Object
readonly
Returns the value of attribute format.
-
.mapping_class ⇒ Object
readonly
Returns the value of attribute mapping_class.
Class Method Summary collapse
- .mappings_class_for(format) ⇒ Object
- .register(format, mapping_class:, adapter_class:, transformer:) ⇒ Object
- .registered_formats ⇒ Object
- .transformer_for(format) ⇒ Object
Class Attribute Details
.adapter_class ⇒ Object (readonly)
Returns the value of attribute adapter_class.
5 6 7 |
# File 'lib/lutaml/model/format_registry.rb', line 5 def adapter_class @adapter_class end |
.format ⇒ Object (readonly)
Returns the value of attribute format.
5 6 7 |
# File 'lib/lutaml/model/format_registry.rb', line 5 def format @format end |
.mapping_class ⇒ Object (readonly)
Returns the value of attribute mapping_class.
5 6 7 |
# File 'lib/lutaml/model/format_registry.rb', line 5 def mapping_class @mapping_class end |
Class Method Details
.mappings_class_for(format) ⇒ Object
30 31 32 |
# File 'lib/lutaml/model/format_registry.rb', line 30 def mappings_class_for(format) registered_formats.dig(format, :mapping_class) end |
.register(format, mapping_class:, adapter_class:, transformer:) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/lutaml/model/format_registry.rb', line 7 def register(format, mapping_class:, adapter_class:, transformer:) registered_formats[format] = { mapping_class: mapping_class, transformer: transformer, } ::Lutaml::Model::Type::Value.register_format_to_from_methods(format) ::Lutaml::Model::Serialize.register_format_mapping_method(format) ::Lutaml::Model::Serialize.register_from_format_method(format) ::Lutaml::Model::Serialize.register_to_format_method(format) Lutaml::Model::Config.set_adapter_for(format, adapter_class) Lutaml::Model::Config.define_singleton_method(:"#{format}_adapter") do @adapters[format] || adapter_class end Lutaml::Model::Config.define_singleton_method(:"#{format}_adapter=") do |adapter_klass| @adapters ||= {} @adapters[format] = adapter_klass end end |
.registered_formats ⇒ Object
38 39 40 |
# File 'lib/lutaml/model/format_registry.rb', line 38 def registered_formats @registered_formats ||= {} end |
.transformer_for(format) ⇒ Object
34 35 36 |
# File 'lib/lutaml/model/format_registry.rb', line 34 def transformer_for(format) registered_formats.dig(format, :transformer) end |