lib/runcible/base.rb in runcible-1.0.0 vs lib/runcible/base.rb in runcible-1.0.2

- old
+ new

@@ -22,23 +22,29 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'rest_client' require 'oauth' require 'json' +require 'thread' module Runcible class Base def initialize(config={}) + @mutex = Mutex.new @config = config end + def lazy_config=(a_block) + @mutex.synchronize { @lazy_config = a_block } + end + def config - if defined?(@config) + @mutex.synchronize do + @config = @lazy_config.call if defined?(@lazy_config) + raise Runcible::ConfigurationUndefinedError, Runcible::ConfigurationUndefinedError.message unless @config @config - else - raise Runcible::ConfigurationUndefinedError, Runcible::ConfigurationUndefinedError.message end end def path(*args) self.class.path(*args)