Sha256: a954244e19e292e2ac4e7c3444218078a5adec8044aa486ce3a2c55fa9c1e8e7
Contents?: true
Size: 843 Bytes
Versions: 3
Compression:
Stored size: 843 Bytes
Contents
# frozen_string_literal: true # @api private # @since 0.1.0 class SmartCore::Injection::Locator::Dependency # @return [void] # # @api private # @since 0.1.0 def initialize @binded = false @value = nil @barrier = SmartCore::Engine::Lock.new end # @param block [Block] # @return [Any] # # @api private # @since 0.1.0 def rebind(&block) with_barrier do @binded = false bind(&block) end end # @param block [Block] # @return [Any] # # @api public # @since 0.7.0 def bind(&block) with_barrier do if @binded @value else @binded = true @value = yield end end end private # @param block [Block] # @return [Any] # # @api private # @since 0.1.0 def with_barrier(&block) @barrier.synchronize(&block) end end
Version data entries
3 entries across 3 versions & 1 rubygems