Class: SmartIoC::Scopes::Request
- Defined in:
- lib/smart_ioc/scopes/request.rb
Overview
Request scope instantiates new bean instance if it’s not present in Thread.current
Constant Summary collapse
- VALUE =
:request
- KEY =
:__SmartIoC
Instance Method Summary collapse
- #clear ⇒ Object
- #force_clear ⇒ Object
- #get_bean(klass) ⇒ Object
-
#initialize ⇒ Request
constructor
A new instance of Request.
- #save_bean(klass, bean) ⇒ Object
Constructor Details
#initialize ⇒ Request
Returns a new instance of Request.
7 8 9 |
# File 'lib/smart_ioc/scopes/request.rb', line 7 def initialize clear end |
Instance Method Details
#clear ⇒ Object
26 27 28 29 30 |
# File 'lib/smart_ioc/scopes/request.rb', line 26 def clear Thread.current[KEY] = {} @beans = Thread.current[KEY] nil end |
#force_clear ⇒ Object
32 33 34 |
# File 'lib/smart_ioc/scopes/request.rb', line 32 def force_clear clear end |
#get_bean(klass) ⇒ Object
14 15 16 |
# File 'lib/smart_ioc/scopes/request.rb', line 14 def get_bean(klass) @beans[klass] end |