Class: Lutaml::Model::Configuration
- Inherits:
-
Object
- Object
- Lutaml::Model::Configuration
- Defined in:
- lib/lutaml/model/configuration.rb
Overview
Single source of truth for Lutaml::Model configuration.
Adapter methods delegate to AdapterResolver. This class retains the configure block API, register, and non-adapter settings.
Instance Attribute Summary collapse
-
#default_register ⇒ Object
(also: #default_context_id)
Returns the value of attribute default_register.
Instance Method Summary collapse
-
#adapter_for(format) ⇒ Object
Dynamic accessor for adapter types — delegates to AdapterResolver.
- #configure {|_self| ... } ⇒ Object
- #configured? ⇒ Boolean
-
#get_adapter(format) ⇒ Object
Get adapter class for a format.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #mappings_class_for(format) ⇒ Object
-
#reset! ⇒ Object
Reset configuration to defaults.
-
#set_adapter(format, adapter_type) ⇒ Object
Dynamic setter for adapter types — delegates to AdapterResolver.
- #to_h ⇒ Object
- #transformer_for(format) ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
19 20 21 22 |
# File 'lib/lutaml/model/configuration.rb', line 19 def initialize @default_register = :default @configured = false end |
Instance Attribute Details
#default_register ⇒ Object Also known as: default_context_id
Returns the value of attribute default_register.
17 18 19 |
# File 'lib/lutaml/model/configuration.rb', line 17 def default_register @default_register end |
Instance Method Details
#adapter_for(format) ⇒ Object
Dynamic accessor for adapter types — delegates to AdapterResolver
35 36 37 |
# File 'lib/lutaml/model/configuration.rb', line 35 def adapter_for(format) AdapterResolver.configured_type(format) end |
#configure {|_self| ... } ⇒ Object
24 25 26 27 28 |
# File 'lib/lutaml/model/configuration.rb', line 24 def configure yield self if block_given? @configured = true self end |
#configured? ⇒ Boolean
30 31 32 |
# File 'lib/lutaml/model/configuration.rb', line 30 def configured? @configured end |
#get_adapter(format) ⇒ Object
Get adapter class for a format
45 46 47 |
# File 'lib/lutaml/model/configuration.rb', line 45 def get_adapter(format) AdapterResolver.adapter_for(format) end |
#mappings_class_for(format) ⇒ Object
78 79 80 |
# File 'lib/lutaml/model/configuration.rb', line 78 def mappings_class_for(format) Lutaml::Model::FormatRegistry.mappings_class_for(format) end |
#reset! ⇒ Object
Reset configuration to defaults
64 65 66 67 68 69 |
# File 'lib/lutaml/model/configuration.rb', line 64 def reset! @default_register = :default @configured = false AdapterResolver.reset! AdapterScope.reset! end |
#set_adapter(format, adapter_type) ⇒ Object
Dynamic setter for adapter types — delegates to AdapterResolver
40 41 42 |
# File 'lib/lutaml/model/configuration.rb', line 40 def set_adapter(format, adapter_type) AdapterResolver.set_adapter_type(format, adapter_type) end |
#to_h ⇒ Object
71 72 73 74 75 76 |
# File 'lib/lutaml/model/configuration.rb', line 71 def to_h { default_register: @default_register, configured: @configured, } end |
#transformer_for(format) ⇒ Object
82 83 84 |
# File 'lib/lutaml/model/configuration.rb', line 82 def transformer_for(format) Lutaml::Model::FormatRegistry.transformer_for(format) end |