Sha256: d22e31fc79957085332f21b0e00e341f7f2f95b486a274438faa18900493e65f

Contents?: true

Size: 682 Bytes

Versions: 35

Compression:

Stored size: 682 Bytes

Contents

# Request scope instantiates new bean instance if it's not present in Thread.current
class SmartIoC::Scopes::Request < SmartIoC::Scopes::Singleton
  VALUE = :request
  KEY   = :__SmartIoC

  # @param bean_factory bean factory
  def initialize
    clear
  end


  # @param klass [Class] bean class
  # @returns bean instance or nil if not stored
  def get_bean(klass)
    @beans[klass]
  end

  # @param klass [Class] bean class
  # @param bean [Any Object] bean object
  # @returns nil
  def save_bean(klass, bean)
    @beans[klass] = bean
    nil
  end

  def clear
    Thread.current[KEY] = {}
    @beans = Thread.current[KEY]
    nil
  end

  def force_clear
    clear
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
smart_ioc-0.5.2 lib/smart_ioc/scopes/request.rb
smart_ioc-0.5.1 lib/smart_ioc/scopes/request.rb
smart_ioc-0.5.0 lib/smart_ioc/scopes/request.rb
smart_ioc-0.3.9 lib/smart_ioc/scopes/request.rb
smart_ioc-0.4.0 lib/smart_ioc/scopes/request.rb
smart_ioc-0.3.8 lib/smart_ioc/scopes/request.rb
smart_ioc-0.3.7 lib/smart_ioc/scopes/request.rb
smart_ioc-0.3.6 lib/smart_ioc/scopes/request.rb
smart_ioc-0.3.5 lib/smart_ioc/scopes/request.rb
smart_ioc-0.3.2 lib/smart_ioc/scopes/request.rb
smart_ioc-0.3.1 lib/smart_ioc/scopes/request.rb
smart_ioc-0.3.0 lib/smart_ioc/scopes/request.rb
smart_ioc-0.2.5 lib/smart_ioc/scopes/request.rb
smart_ioc-0.2.4 lib/smart_ioc/scopes/request.rb
smart_ioc-0.2.3 lib/smart_ioc/scopes/request.rb
smart_ioc-0.2.2 lib/smart_ioc/scopes/request.rb
smart_ioc-0.2.1 lib/smart_ioc/scopes/request.rb
smart_ioc-0.2.0 lib/smart_ioc/scopes/request.rb
smart_ioc-0.1.30 lib/smart_ioc/scopes/request.rb
smart_ioc-0.1.29 lib/smart_ioc/scopes/request.rb