class ClimateControl::Environment

Public Class Methods

new() click to toggle source
# File lib/climate_control/environment.rb, line 7
def initialize
  @semaphore = Mutex.new
  @owner = nil
end

Public Instance Methods

synchronize() { || ... } click to toggle source
# File lib/climate_control/environment.rb, line 14
def synchronize
  if @owner == Thread.current
    return yield if block_given?
  end

  @semaphore.synchronize do
    @owner = Thread.current
    yield if block_given?
  ensure
    @owner = nil
  end
end

Private Instance Methods

env() click to toggle source
# File lib/climate_control/environment.rb, line 29
def env
  ENV
end