diff --git a/docs/images/providers/factory_attribute_injections.png b/docs/images/providers/factory_attribute_injections.png index 01273e8a..df963f0d 100644 Binary files a/docs/images/providers/factory_attribute_injections.png and b/docs/images/providers/factory_attribute_injections.png differ diff --git a/docs/providers/factory.rst b/docs/providers/factory.rst index 8bab4f5a..01e431e8 100644 --- a/docs/providers/factory.rst +++ b/docs/providers/factory.rst @@ -72,7 +72,7 @@ So, please, follow the example below: Factory providers and attribute injections ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Example below shows how to create ``Factory`` of particular class with +Example below shows how to create ``di.Factory`` of particular class with attribute injections. Those injections are done by setting specified attributes with injectable values right after object's creation. diff --git a/examples/providers/factory_attribute_injections.py b/examples/providers/factory_attribute_injections.py index 02a46d25..96792194 100644 --- a/examples/providers/factory_attribute_injections.py +++ b/examples/providers/factory_attribute_injections.py @@ -1,7 +1,6 @@ -"""`Factory` providers with attribute injections example.""" +"""`di.Factory` providers with attribute injections example.""" -from dependency_injector.providers import Factory -from dependency_injector.injections import Attribute +import dependency_injector as di class User(object): @@ -24,11 +23,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, - Attribute('main_photo', photos_factory), - Attribute('credit_card', credit_cards_factory)) +credit_cards_factory = di.Factory(CreditCard) +photos_factory = di.Factory(Photo) +users_factory = di.Factory(User, + di.Attribute('main_photo', photos_factory), + di.Attribute('credit_card', credit_cards_factory)) # Creating several User objects: user1 = users_factory()