Class: Kumi::Configuration
- Inherits:
-
Object
- Object
- Kumi::Configuration
- Defined in:
- lib/kumi/configuration.rb
Overview
Holds the configuration state for the Kumi compiler and runtime. This object is yielded to the user in the ‘Kumi.configure` block.
Instance Attribute Summary collapse
-
#cache_path ⇒ Object
The directory where compiled schemas are stored as cached Ruby files.
-
#code_version ⇒ Object
A fingerprint of the COMPILER itself, folded into cache keys so that a change to the analyzer/codegen invalidates cached generated code even when the schema (and thus its digest) is unchanged.
-
#compilation_mode ⇒ Object
The compilation strategy.
-
#decimal_coercion_mode ⇒ Object
Decimal coercion behavior for inputs declared as ‘decimal` type.
-
#force_recompile ⇒ Object
A master switch to bypass the cache and force recompilation on every run.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
31 32 33 34 35 36 37 38 |
# File 'lib/kumi/configuration.rb', line 31 def initialize # Set smart, environment-aware defaults. @cache_path = default_cache_path @compilation_mode = default_compilation_mode @force_recompile = false @decimal_coercion_mode = :automatic @code_version = nil end |
Instance Attribute Details
#cache_path ⇒ Object
The directory where compiled schemas are stored as cached Ruby files. On file-based systems, this is crucial for performance.
12 13 14 |
# File 'lib/kumi/configuration.rb', line 12 def cache_path @cache_path end |
#code_version ⇒ Object
A fingerprint of the COMPILER itself, folded into cache keys so that a change to the analyzer/codegen invalidates cached generated code even when the schema (and thus its digest) is unchanged. Without this, editing the compiler and re-running silently reuses stale generated code from ‘cache_path` — a debugging trap. Override (e.g. to the gem version in production) via `Kumi.configure { |c| c.code_version = … }`.
46 47 48 |
# File 'lib/kumi/configuration.rb', line 46 def code_version @code_version ||= compute_code_version end |
#compilation_mode ⇒ Object
The compilation strategy.
:jit (Just-in-Time): Compiles schemas on-the-fly at boot time if the
source has changed. Ideal for development.
:aot (Ahead-of-Time): Expects schemas to be precompiled via a build
task. Raises an error at runtime if a compiled file is missing.
Ideal for production and test environments.
20 21 22 |
# File 'lib/kumi/configuration.rb', line 20 def compilation_mode @compilation_mode end |
#decimal_coercion_mode ⇒ Object
Decimal coercion behavior for inputs declared as ‘decimal` type. :automatic (default): Automatically coerce inputs to BigDecimal in Ruby :explicit: User must explicitly call to_decimal() in the schema
29 30 31 |
# File 'lib/kumi/configuration.rb', line 29 def decimal_coercion_mode @decimal_coercion_mode end |
#force_recompile ⇒ Object
A master switch to bypass the cache and force recompilation on every run. Useful for debugging the compiler itself.
24 25 26 |
# File 'lib/kumi/configuration.rb', line 24 def force_recompile @force_recompile end |