class SmartIoC::Scopes::Singleton

Singleton scope returns same bean instance on each call

Constants

VALUE

Public Class Methods

new() click to toggle source
# File lib/smart_ioc/scopes/singleton.rb, line 5
def initialize
  @beans = {}
end

Public Instance Methods

clear() click to toggle source
# File lib/smart_ioc/scopes/singleton.rb, line 23
def clear
  # do nothing as singleton beans are being instantiated only once
end
force_clear() click to toggle source
# File lib/smart_ioc/scopes/singleton.rb, line 27
def force_clear
  @beans = {}
  nil
end
get_bean(klass) click to toggle source

@param klass [Class] bean class @returns bean instance or nil if not stored

# File lib/smart_ioc/scopes/singleton.rb, line 11
def get_bean(klass)
  @beans[klass]
end
save_bean(klass, bean) click to toggle source

@param klass [Class] bean class @param bean [Any Object] bean object @returns nil

# File lib/smart_ioc/scopes/singleton.rb, line 18
def save_bean(klass, bean)
  @beans[klass] = bean
  nil
end