Class: Configurate::Provider::Dynamic

Inherits:
Base
  • Object
show all
Defined in:
lib/configurate/provider/dynamic.rb

Overview

This provider knows nothing upon initialization, however if you access a setting ending with = and give one argument to that call it remembers that setting, stripping the = and will return it on the next call without =. Sending reset_dynamic! to it will make it forget all settings. Also assigning nil will have the effect of it forgetting a setting.

Instance Method Summary collapse

Methods inherited from Base

#lookup

Instance Method Details

#lookup_path(setting_path, *args) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/configurate/provider/dynamic.rb', line 10

def lookup_path(setting_path, *args)
  if setting_path.to_s == "reset_dynamic!"
    @settings = nil
    return true
  end

  if setting_path.setter? && args.length > 0
    *root, key = setting_path.to_a
    hash = root.inject(settings) {|hash, key| hash[key] }
    hash[key] = extract_value(args)
  end

  Provider.lookup_in_hash setting_path, settings
end