Class: Smplkit::Config::ConfigEnvironment
- Inherits:
-
Object
- Object
- Smplkit::Config::ConfigEnvironment
- Defined in:
- lib/smplkit/config/models.rb
Overview
Per-environment value overrides for a Config.
Read-only inspection container. Mutation is performed via Config‘s setters with environment: (e.g. cfg.set_string(“k”, “v”, environment: “production”)).
Per ADR-024 §2.4 the wire shape for env overrides is flat —+{key: rawValue}+ — so the in-memory representation is simply a Hash of raw values, with no typed wrapper.
Instance Method Summary collapse
- #_replace_raw(values) ⇒ Object
-
#initialize(values: nil) ⇒ ConfigEnvironment
constructor
A new instance of ConfigEnvironment.
-
#values ⇒ Object
Returns overrides as a plain Hash { “key” => raw_value }.
-
#values_raw ⇒ Object
Returns overrides as a plain Hash { “key” => raw_value }.
Constructor Details
#initialize(values: nil) ⇒ ConfigEnvironment
Returns a new instance of ConfigEnvironment.
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/smplkit/config/models.rb', line 49 def initialize(values: nil) @values_raw = {} return unless values values.each do |k, v| # Tolerate a legacy +{ "value" => raw, "type" => t }+ wrapper in # case a caller passes the old shape; unwrap to the raw value. @values_raw[k] = v.is_a?(Hash) && v.key?("value") ? v["value"] : v end end |
Instance Method Details
#_replace_raw(values) ⇒ Object
72 73 74 |
# File 'lib/smplkit/config/models.rb', line 72 def _replace_raw(values) @values_raw = values end |
#values ⇒ Object
Returns overrides as a plain Hash { “key” => raw_value }.
61 62 63 |
# File 'lib/smplkit/config/models.rb', line 61 def values @values_raw.dup end |
#values_raw ⇒ Object
Returns overrides as a plain Hash { “key” => raw_value }. Retained as a separate accessor for backward compatibility; identical to values now that env overrides are stored flat.
68 69 70 |
# File 'lib/smplkit/config/models.rb', line 68 def values_raw @values_raw.dup end |