Class: Persey::Loader
- Inherits:
-
Object
- Object
- Persey::Loader
- Defined in:
- lib/persey/loader.rb
Instance Attribute Summary collapse
-
#configs ⇒ Object
Returns the value of attribute configs.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(configs) ⇒ Loader
constructor
A new instance of Loader.
- #load(env) ⇒ Object
Constructor Details
#initialize(configs) ⇒ Loader
Returns a new instance of Loader.
14 15 16 |
# File 'lib/persey/loader.rb', line 14 def initialize(configs) @configs = configs end |
Instance Attribute Details
#configs ⇒ Object
Returns the value of attribute configs.
5 6 7 |
# File 'lib/persey/loader.rb', line 5 def configs @configs end |
Class Method Details
.load(configs, env) ⇒ Object
8 9 10 11 |
# File 'lib/persey/loader.rb', line 8 def load(configs, env) l = new(configs) l.load(env) end |
Instance Method Details
#load(env) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/persey/loader.rb', line 18 def load(env) @defaults = {} configs.each do |pdc| klass = pdc[:class] raw_config = klass.load(pdc[:file], env, opts: pdc[:opts]) env_config = raw_config[env].nil? ? raw_config : raw_config[env] n = pdc[:namespace] if n.nil? @defaults.merge!(env_config) else @defaults[n].is_a?(Hash) ? @defaults[n].merge!(env_config) : @defaults[n] = env_config end end @defaults end |