Class: Callme::Scopes::SingletonScope
- Inherits:
-
Object
- Object
- Callme::Scopes::SingletonScope
- Defined in:
- lib/callme/scopes/singleton_scope.rb
Overview
Singleton scope returns the same dep instance on each call
Instance Method Summary collapse
-
#delete_dep(dep_metadata) ⇒ Object
Delete dep from scope.
-
#get_dep(dep_metadata) ⇒ Object
Returns the same dep instance on each call.
-
#initialize(dep_factory) ⇒ SingletonScope
constructor
Constructon.
Constructor Details
#initialize(dep_factory) ⇒ SingletonScope
Constructon
7 8 9 |
# File 'lib/callme/scopes/singleton_scope.rb', line 7 def initialize(dep_factory) @dep_factory = dep_factory end |
Instance Method Details
#delete_dep(dep_metadata) ⇒ Object
Delete dep from scope
21 22 23 |
# File 'lib/callme/scopes/singleton_scope.rb', line 21 def delete_dep() store.delete(.name) end |
#get_dep(dep_metadata) ⇒ Object
Returns the same dep instance on each call
15 16 17 |
# File 'lib/callme/scopes/singleton_scope.rb', line 15 def get_dep() store[.name] || @dep_factory.create_dep_and_save(, store) end |