Class: Callme::Scopes::RequestScope
- Inherits:
-
Object
- Object
- Callme::Scopes::RequestScope
- Defined in:
- lib/callme/scopes/request_scope.rb
Overview
Request scope instantiates new dep instance on each new HTTP request
Instance Method Summary collapse
-
#delete_dep(dep_metadata) ⇒ Object
Delete dep from scope.
-
#get_dep(dep_metadata) ⇒ Object
Returns a dep from the
RequestStore
RequestStore is a wrapper for Thread.current which clears it on each new HTTP request. -
#initialize(dep_factory) ⇒ RequestScope
constructor
Constructon.
Constructor Details
#initialize(dep_factory) ⇒ RequestScope
Constructon
9 10 11 |
# File 'lib/callme/scopes/request_scope.rb', line 9 def initialize(dep_factory) @dep_factory = dep_factory end |
Instance Method Details
#delete_dep(dep_metadata) ⇒ Object
Delete dep from scope
25 26 27 |
# File 'lib/callme/scopes/request_scope.rb', line 25 def delete_dep() store.delete(.name) end |
#get_dep(dep_metadata) ⇒ Object
Returns a dep from the RequestStore
RequestStore is a wrapper for Thread.current which clears it on each new HTTP request
19 20 21 |
# File 'lib/callme/scopes/request_scope.rb', line 19 def get_dep() store[.name] || @dep_factory.create_dep_and_save(, store) end |