Class: SmartIoC::Scopes::Singleton
- Inherits:
-
Object
- Object
- SmartIoC::Scopes::Singleton
- Defined in:
- lib/smart_ioc/scopes/singleton.rb
Overview
Singleton scope returns same bean instance on each call
Direct Known Subclasses
Constant Summary collapse
- VALUE =
:singleton
Instance Method Summary collapse
- #clear ⇒ Object
- #force_clear ⇒ Object
- #get_bean(klass) ⇒ Object
-
#initialize ⇒ Singleton
constructor
A new instance of Singleton.
- #save_bean(klass, bean) ⇒ Object
Constructor Details
#initialize ⇒ Singleton
Returns a new instance of Singleton.
5 6 7 |
# File 'lib/smart_ioc/scopes/singleton.rb', line 5 def initialize @beans = {} end |
Instance Method Details
#clear ⇒ Object
23 24 25 |
# File 'lib/smart_ioc/scopes/singleton.rb', line 23 def clear # do nothing as singleton beans are being instantiated only once end |
#force_clear ⇒ Object
27 28 29 30 |
# File 'lib/smart_ioc/scopes/singleton.rb', line 27 def force_clear @beans = {} nil end |
#get_bean(klass) ⇒ Object
11 12 13 |
# File 'lib/smart_ioc/scopes/singleton.rb', line 11 def get_bean(klass) @beans[klass] end |