Sha256: a128c027c766e17925e492c739449b25c73a1f261fff69d562af6806f42284af

Contents?: true

Size: 588 Bytes

Versions: 35

Compression:

Stored size: 588 Bytes

Contents

# Singleton scope returns same bean instance on each call
class SmartIoC::Scopes::Singleton
  VALUE = :singleton

  def initialize
    @beans = {}
  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
    # do nothing as singleton beans are being instantiated only once
  end

  def force_clear
    @beans = {}
    nil
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

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