Class: Configurate::Provider::StringHash
- Defined in:
- lib/configurate/provider/string_hash.rb
Overview
This provider takes a nested string keyed hash and does nested lookups in it.
Instance Method Summary collapse
-
#initialize(hash, namespace: nil, required: true, raise_on_missing: false, source: nil) ⇒ StringHash
constructor
A new instance of StringHash.
- #lookup_path(setting_path, *_) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(hash, namespace: nil, required: true, raise_on_missing: false, source: nil) ⇒ StringHash
Returns a new instance of StringHash.
15 16 17 18 19 20 21 22 |
# File 'lib/configurate/provider/string_hash.rb', line 15 def initialize hash, namespace: nil, required: true, raise_on_missing: false, source: nil raise ArgumentError, "Please provide a hash" unless hash.is_a?(Hash) @required = required @raise_on_missing = raise_on_missing @source = source @settings = root_from hash, namespace end |
Instance Method Details
#lookup_path(setting_path, *_) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/configurate/provider/string_hash.rb', line 24 def lookup_path setting_path, *_ Provider.lookup_in_hash(setting_path, @settings) { raise MissingSetting.new "#{setting_path} is not a valid setting." if @raise_on_missing nil } end |