lib/rubber/configuration.rb in rubber-3.0.0 vs lib/rubber/configuration.rb in rubber-3.0.1
- old
+ new
@@ -3,19 +3,24 @@
require 'rubber/instance'
require 'rubber/generator'
module Rubber
module Configuration
+ extend MonitorMixin
@@configurations = {}
def self.get_configuration(env=nil, root=nil)
key = "#{env}-#{root}"
- unless @@configurations[key]
- @@configurations[key] = ConfigHolder.new(env, root)
- @@configurations[key].load()
+
+ synchronize do
+ unless @@configurations[key]
+ @@configurations[key] = ConfigHolder.new(env, root)
+ @@configurations[key].load()
+ end
end
+
return @@configurations[key]
end
def self.rubber_env
raise "This convenience method needs Rubber.env to be set" unless Rubber.env
@@ -26,9 +31,15 @@
end
def self.rubber_instances
raise "This convenience method needs Rubber.env to be set" unless Rubber.env
Rubber::Configuration.get_configuration(Rubber.env).instance
+ end
+
+ def self.reset
+ synchronize do
+ @@configurations.clear
+ end
end
class ConfigHolder
def initialize(env=nil, root=nil)
@env = env