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”)).
An override stores only the raw value; the declared type and description come from the base item, so an item’s type and description are ignored when an environment override is supplied.
Instance Method Summary collapse
- #_replace_raw(values) ⇒ Object
-
#initialize(values: nil) ⇒ ConfigEnvironment
constructor
A new instance of ConfigEnvironment.
-
#values ⇒ Hash{String => Object}
Returns overrides as a plain Hash { “key” => raw_value }.
-
#values_raw ⇒ Hash{String => Object}
Returns overrides as a plain Hash { “key” => raw_value }.
Constructor Details
#initialize(values: nil) ⇒ ConfigEnvironment
Returns a new instance of ConfigEnvironment.
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/smplkit/config/models.rb', line 61 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
90 91 92 |
# File 'lib/smplkit/config/models.rb', line 90 def _replace_raw(values) @values_raw = values end |
#values ⇒ Hash{String => Object}
Returns overrides as a plain Hash { “key” => raw_value }.
76 77 78 |
# File 'lib/smplkit/config/models.rb', line 76 def values @values_raw.dup end |
#values_raw ⇒ Hash{String => 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.
86 87 88 |
# File 'lib/smplkit/config/models.rb', line 86 def values_raw @values_raw.dup end |