From 839888f445fe62f6493819c70d34a793b3e7a160 Mon Sep 17 00:00:00 2001 From: Roman Mogilatov Date: Thu, 16 Jul 2015 02:50:55 +0300 Subject: [PATCH] Adding some minor updates for providers delegation example --- docs/providers/delegation.rst | 5 +++-- examples/providers/delegation.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/providers/delegation.rst b/docs/providers/delegation.rst index 585dcdc1..cde345a3 100644 --- a/docs/providers/delegation.rst +++ b/docs/providers/delegation.rst @@ -9,6 +9,7 @@ Example: from objects.providers import Factory from objects.providers import Singleton + from objects.providers import Delegate from objects.injections import KwArg @@ -38,7 +39,7 @@ Example: def __init__(self, users_factory): """Initializer. - :param users_factory: objects.providers.Factory + :param users_factory: (objects.providers.Factory) -> User :return: """ self.users_factory = users_factory @@ -60,7 +61,7 @@ Example: # Users factory and UserService provider: users_factory = Factory(User) users_service = Singleton(UserService, - KwArg('users_factory', users_factory.delegate())) + KwArg('users_factory', Delegate(users_factory))) # Creating several User objects: diff --git a/examples/providers/delegation.py b/examples/providers/delegation.py index cfaff6d8..2d8501d4 100644 --- a/examples/providers/delegation.py +++ b/examples/providers/delegation.py @@ -2,6 +2,7 @@ from objects.providers import Factory from objects.providers import Singleton +from objects.providers import Delegate from objects.injections import KwArg @@ -31,7 +32,7 @@ class UserService(object): def __init__(self, users_factory): """Initializer. - :param users_factory: objects.providers.Factory + :param users_factory: (objects.providers.Factory) -> User :return: """ self.users_factory = users_factory @@ -53,7 +54,7 @@ class UserService(object): # Users factory and UserService provider: users_factory = Factory(User) users_service = Singleton(UserService, - KwArg('users_factory', users_factory.delegate())) + KwArg('users_factory', Delegate(users_factory))) # Creating several User objects: