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 =.

Instance Method Summary collapse

Methods inherited from Base

#lookup

Constructor Details

#initializeDynamic

Returns a new instance of Dynamic.



7
8
9
# File 'lib/configurate/provider/dynamic.rb', line 7

def initialize
  @settings = {}
end

Instance Method Details

#lookup_path(setting_path, *args) ⇒ Object



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

def lookup_path(setting_path, *args)      
  key = setting_path.to_s
  
  if setting_path.is_setter? && args.length > 0
    value = args.first
    value = value.get if value.respond_to?(:_proxy?) && value._proxy?
    @settings[key] = value
  end
  
  @settings[key]
end