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
-
#conversion_cache ⇒ Object
Store consulted by classes that declare
cache_conversions. -
#default_register ⇒ Object
(also: #default_context_id)
Returns the value of attribute default_register.
-
#xml_plan_fast_path ⇒ Object
Experimental: whole-document native materialization for plan- compilable XML models (Leptris::XML::Descriptor walk).
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.
24 25 26 27 28 29 |
# File 'lib/lutaml/model/configuration.rb', line 24 def initialize @default_register = :default @conversion_cache = nil @configured = false @xml_plan_fast_path = false end |
Instance Attribute Details
#conversion_cache ⇒ Object
Store consulted by classes that declare cache_conversions.
Defaults to a memory-backed Lutaml::Store::BasicStore when the
lutaml-store gem is loaded (the application opts in by adding it
to its Gemfile and requiring "lutaml/store"). Assign any object
responding to #get/#set to override, false to disable caching
entirely, or nil to return to auto-detection.
43 44 45 46 47 |
# File 'lib/lutaml/model/configuration.rb', line 43 def conversion_cache return if @conversion_cache == false @conversion_cache ||= default_conversion_cache end |
#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 |
#xml_plan_fast_path ⇒ Object
Experimental: whole-document native materialization for plan- compilable XML models (Leptris::XML::Descriptor walk). Opt-in while the full semantics audit completes.
21 22 23 |
# File 'lib/lutaml/model/configuration.rb', line 21 def xml_plan_fast_path @xml_plan_fast_path end |
Instance Method Details
#adapter_for(format) ⇒ Object
Dynamic accessor for adapter types — delegates to AdapterResolver
54 55 56 |
# File 'lib/lutaml/model/configuration.rb', line 54 def adapter_for(format) AdapterResolver.configured_type(format) end |
#configure {|_self| ... } ⇒ Object
31 32 33 34 35 |
# File 'lib/lutaml/model/configuration.rb', line 31 def configure yield self if block_given? @configured = true self end |
#configured? ⇒ Boolean
49 50 51 |
# File 'lib/lutaml/model/configuration.rb', line 49 def configured? @configured end |
#get_adapter(format) ⇒ Object
Get adapter class for a format
64 65 66 |
# File 'lib/lutaml/model/configuration.rb', line 64 def get_adapter(format) AdapterResolver.adapter_for(format) end |
#mappings_class_for(format) ⇒ Object
98 99 100 |
# File 'lib/lutaml/model/configuration.rb', line 98 def mappings_class_for(format) Lutaml::Model::FormatRegistry.mappings_class_for(format) end |
#reset! ⇒ Object
Reset configuration to defaults
83 84 85 86 87 88 89 |
# File 'lib/lutaml/model/configuration.rb', line 83 def reset! @default_register = :default @conversion_cache = nil @configured = false AdapterResolver.reset! AdapterScope.reset! end |
#set_adapter(format, adapter_type) ⇒ Object
Dynamic setter for adapter types — delegates to AdapterResolver
59 60 61 |
# File 'lib/lutaml/model/configuration.rb', line 59 def set_adapter(format, adapter_type) AdapterResolver.set_adapter_type(format, adapter_type) end |
#to_h ⇒ Object
91 92 93 94 95 96 |
# File 'lib/lutaml/model/configuration.rb', line 91 def to_h { default_register: @default_register, configured: @configured, } end |
#transformer_for(format) ⇒ Object
102 103 104 |
# File 'lib/lutaml/model/configuration.rb', line 102 def transformer_for(format) Lutaml::Model::FormatRegistry.transformer_for(format) end |