Class: Armoire

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/armoire.rb,
lib/armoire/railtie.rb,
lib/armoire/setting.rb,
lib/armoire/version.rb

Defined Under Namespace

Classes: ConfigSettingMissing, MissingSettingsFile, Railtie, Setting

Constant Summary collapse

VERSION =
"1.4.1"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#environmentObject



30
31
32
# File 'lib/armoire.rb', line 30

def environment
  @environment ||= ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
end

#settingsObject

Returns the value of attribute settings.



11
12
13
# File 'lib/armoire.rb', line 11

def settings
  @settings
end

Class Method Details

.[](key) ⇒ Object



14
15
16
# File 'lib/armoire.rb', line 14

def self.[](key)
  instance.settings[key]
end

.environmentObject



26
27
28
# File 'lib/armoire.rb', line 26

def self.environment
  instance.environment
end

.environment=(environment) ⇒ Object



22
23
24
# File 'lib/armoire.rb', line 22

def self.environment=(environment)
  instance.environment = environment
end

.load!(path_to_config_file) ⇒ Object



18
19
20
# File 'lib/armoire.rb', line 18

def self.load!(path_to_config_file)
  instance.settings = Setting.new(instance.load_settings(path_to_config_file))
end

Instance Method Details

#load_settings(path_to_config_file) ⇒ Object



34
35
36
37
38
# File 'lib/armoire.rb', line 34

def load_settings(path_to_config_file)
  YAML.load(ERB.new(File.read(path_to_config_file)).result)[environment]
rescue Errno::ENOENT => e
  raise MissingSettingsFile.new('The settings file cannot be found')
end