diff --git a/docs/images/providers/factory_method_injections.png b/docs/images/providers/factory_method_injections.png index a30cf299..0b0362b4 100644 Binary files a/docs/images/providers/factory_method_injections.png and b/docs/images/providers/factory_method_injections.png differ diff --git a/docs/providers/factory.rst b/docs/providers/factory.rst index 3a42d780..8bab4f5a 100644 --- a/docs/providers/factory.rst +++ b/docs/providers/factory.rst @@ -86,13 +86,13 @@ Example: Factory providers and method injections ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Current example shows how to create ``Factory`` of particular class with +Current example shows how to create ``di.Factory`` of particular class with method injections. Those injections are done by calling of specified method with injectable value right after object's creation and attribute injections are done. Method injections are not very popular in Python due Python best practices -(usage of public attributes instead of setter methods), but it may appear in +(usage of public attributes instead of setter methods), but they may appear in some cases. Example: diff --git a/examples/providers/factory_method_injections.py b/examples/providers/factory_method_injections.py index 0a7af9c0..0e54d305 100644 --- a/examples/providers/factory_method_injections.py +++ b/examples/providers/factory_method_injections.py @@ -1,7 +1,6 @@ -"""`Factory` providers with method injections example.""" +"""`di.Factory` providers with method injections example.""" -from dependency_injector.providers import Factory -from dependency_injector.injections import Method +import dependency_injector as di class User(object): @@ -32,11 +31,11 @@ class CreditCard(object): """Example class CreditCard.""" # User, Photo and CreditCard factories: -credit_cards_factory = Factory(CreditCard) -photos_factory = Factory(Photo) -users_factory = Factory(User, - Method('set_main_photo', photos_factory), - Method('set_credit_card', credit_cards_factory)) +credit_cards_factory = di.Factory(CreditCard) +photos_factory = di.Factory(Photo) +users_factory = di.Factory(User, + di.Method('set_main_photo', photos_factory), + di.Method('set_credit_card', credit_cards_factory)) # Creating several User objects: user1 = users_factory()