Class: Kumi::Configuration

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



30
31
32
33
34
35
36
# File 'lib/kumi/configuration.rb', line 30

def initialize
  # Set smart, environment-aware defaults.
  @cache_path = default_cache_path
  @compilation_mode = default_compilation_mode
  @force_recompile = false
  @decimal_coercion_mode = :automatic
end

Instance Attribute Details

#cache_pathObject

The directory where compiled schemas are stored as cached Ruby files. On file-based systems, this is crucial for performance.



11
12
13
# File 'lib/kumi/configuration.rb', line 11

def cache_path
  @cache_path
end

#compilation_modeObject

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.


19
20
21
# File 'lib/kumi/configuration.rb', line 19

def compilation_mode
  @compilation_mode
end

#decimal_coercion_modeObject

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



28
29
30
# File 'lib/kumi/configuration.rb', line 28

def decimal_coercion_mode
  @decimal_coercion_mode
end

#force_recompileObject

A master switch to bypass the cache and force recompilation on every run. Useful for debugging the compiler itself.



23
24
25
# File 'lib/kumi/configuration.rb', line 23

def force_recompile
  @force_recompile
end