Class: AppConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_app_config.rb

Class Method Summary collapse

Class Method Details

.create(yaml_file, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/simple_app_config.rb', line 5

def self.create(yaml_file, options = {})
  format = options[:format] || :struct
  yaml_data = YAML::load(ERB.new(IO.read(yaml_file)).result)
  data = {}
  data = yaml_data.delete(options[:environment]) if options[:environment]
  data.merge!(yaml_data)
  format == :struct ? OpenStruct.new(data) : data
end