Adding some minor updates for providers delegation example

This commit is contained in:
Roman Mogilatov 2015-07-16 02:50:55 +03:00
parent ec808b1361
commit 839888f445
2 changed files with 6 additions and 4 deletions

View File

@ -9,6 +9,7 @@ Example:
from objects.providers import Factory from objects.providers import Factory
from objects.providers import Singleton from objects.providers import Singleton
from objects.providers import Delegate
from objects.injections import KwArg from objects.injections import KwArg
@ -38,7 +39,7 @@ Example:
def __init__(self, users_factory): def __init__(self, users_factory):
"""Initializer. """Initializer.
:param users_factory: objects.providers.Factory :param users_factory: (objects.providers.Factory) -> User
:return: :return:
""" """
self.users_factory = users_factory self.users_factory = users_factory
@ -60,7 +61,7 @@ Example:
# Users factory and UserService provider: # Users factory and UserService provider:
users_factory = Factory(User) users_factory = Factory(User)
users_service = Singleton(UserService, users_service = Singleton(UserService,
KwArg('users_factory', users_factory.delegate())) KwArg('users_factory', Delegate(users_factory)))
# Creating several User objects: # Creating several User objects:

View File

@ -2,6 +2,7 @@
from objects.providers import Factory from objects.providers import Factory
from objects.providers import Singleton from objects.providers import Singleton
from objects.providers import Delegate
from objects.injections import KwArg from objects.injections import KwArg
@ -31,7 +32,7 @@ class UserService(object):
def __init__(self, users_factory): def __init__(self, users_factory):
"""Initializer. """Initializer.
:param users_factory: objects.providers.Factory :param users_factory: (objects.providers.Factory) -> User
:return: :return:
""" """
self.users_factory = users_factory self.users_factory = users_factory
@ -53,7 +54,7 @@ class UserService(object):
# Users factory and UserService provider: # Users factory and UserService provider:
users_factory = Factory(User) users_factory = Factory(User)
users_service = Singleton(UserService, users_service = Singleton(UserService,
KwArg('users_factory', users_factory.delegate())) KwArg('users_factory', Delegate(users_factory)))
# Creating several User objects: # Creating several User objects: