mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-22 01:26:51 +03:00
Removing delegate option from injections
This commit is contained in:
parent
e38cecfae0
commit
acc9259ddd
|
@ -52,10 +52,9 @@ class UserService(object):
|
|||
|
||||
|
||||
# Users factory and UserService provider:
|
||||
users_factory = Factory(User)
|
||||
users_service = Singleton(UserService,
|
||||
KwArg('users_factory',
|
||||
Delegate(Factory(User))))
|
||||
|
||||
KwArg('users_factory', Delegate(users_factory)))
|
||||
|
||||
# Creating several User objects:
|
||||
user1 = users_service().get_by_id(1)
|
||||
|
|
|
@ -8,18 +8,17 @@ class Injection(object):
|
|||
"""Base injection class."""
|
||||
|
||||
__IS_OBJECTS_INJECTION__ = True
|
||||
__slots__ = ('name', 'injectable', 'delegate')
|
||||
__slots__ = ('name', 'injectable')
|
||||
|
||||
def __init__(self, name, injectable, delegate=False):
|
||||
def __init__(self, name, injectable):
|
||||
"""Initializer."""
|
||||
self.name = name
|
||||
self.injectable = injectable
|
||||
self.delegate = delegate
|
||||
|
||||
@property
|
||||
def value(self):
|
||||
"""Return injectable value."""
|
||||
if is_provider(self.injectable) and not self.delegate:
|
||||
if is_provider(self.injectable):
|
||||
return self.injectable()
|
||||
return self.injectable
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user