lib/armoire.rb in armoire-1.2.1 vs lib/armoire.rb in armoire-1.3.0
- old
+ new
@@ -13,20 +13,25 @@
class Armoire
include Singleton
attr_accessor :settings
+ attr_writer :environment
- def environment
- ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
- end
-
def self.[](key)
instance.settings[key]
end
def self.load!(path_to_config_file)
instance.settings = Setting.new(instance.load_settings(path_to_config_file))
+ end
+
+ def self.environment=(environment)
+ instance.environment = environment
+ end
+
+ def environment
+ @environment ||= ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
end
def load_settings(path_to_config_file)
YAML.load(ERB.new(File.read(path_to_config_file)).result)[environment]
rescue Errno::ENOENT => e