mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-22 09:36:48 +03:00
Refactoring of ProviderDelegate
This commit is contained in:
parent
76e14c1c79
commit
16799e414b
|
@ -41,7 +41,28 @@ class Provider(object):
|
||||||
"""
|
"""
|
||||||
Returns provider delegate.
|
Returns provider delegate.
|
||||||
"""
|
"""
|
||||||
return self.__call__
|
return ProviderDelegate(self)
|
||||||
|
|
||||||
|
|
||||||
|
class ProviderDelegate(Provider):
|
||||||
|
"""
|
||||||
|
Provider's delegate.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, delegated):
|
||||||
|
"""
|
||||||
|
Initializer.
|
||||||
|
|
||||||
|
:type delegated: Provider
|
||||||
|
"""
|
||||||
|
self.delegated = delegated
|
||||||
|
super(ProviderDelegate, self).__init__()
|
||||||
|
|
||||||
|
def __call__(self):
|
||||||
|
"""
|
||||||
|
Returns provided instance.
|
||||||
|
"""
|
||||||
|
return self.delegated.__call__
|
||||||
|
|
||||||
|
|
||||||
def prepare_injections(injections):
|
def prepare_injections(injections):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user