Class: ConfigReader::EnvConfigReader

Inherits:
Hashie::Mash
  • Object
show all
Includes:
FileLoading, Hashie::Extensions::DeepMerge
Defined in:
lib/configreader/env_configreader.rb

Defined Under Namespace

Classes: EnvironmentNotFoundInYaml

Constant Summary collapse

DEFAULT_KEY =
'defaults'

Instance Method Summary collapse

Methods included from FileLoading

#load_config

Constructor Details

#initialize(config) ⇒ EnvConfigReader

Returns a new instance of EnvConfigReader.



14
15
16
17
18
19
20
21
22
# File 'lib/configreader/env_configreader.rb', line 14

def initialize(config)
  config_data = load_config(config)
  env_data = config_data[Rails.env] || {}
  default_data = config_data[DEFAULT_KEY] || {}

  super(default_data)
  self.deep_merge!(env_data)
  raise EnvironmentNotFoundInYaml.new(Rails.env) if self.empty?
end