mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-02-07 07:00:49 +03:00
Update basic factory example and docs
This commit is contained in:
parent
98c4ec71c1
commit
f9b4652e74
Binary file not shown.
Before Width: | Height: | Size: 7.6 KiB After Width: | Height: | Size: 8.2 KiB |
|
@ -1,7 +1,7 @@
|
||||||
Factory providers
|
Factory providers
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
``Factory`` provider creates new instance of specified class on every call.
|
``di.Factory`` provider creates new instance of specified class on every call.
|
||||||
|
|
||||||
Nothing could be better than brief example:
|
Nothing could be better than brief example:
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""`Factory` providers example."""
|
"""`di.Factory` providers example."""
|
||||||
|
|
||||||
from dependency_injector.providers import Factory
|
import dependency_injector as di
|
||||||
|
|
||||||
|
|
||||||
class User(object):
|
class User(object):
|
||||||
|
@ -8,7 +8,7 @@ class User(object):
|
||||||
"""Example class User."""
|
"""Example class User."""
|
||||||
|
|
||||||
# Factory provider creates new instance of specified class on every call.
|
# Factory provider creates new instance of specified class on every call.
|
||||||
users_factory = Factory(User)
|
users_factory = di.Factory(User)
|
||||||
|
|
||||||
# Creating several User objects:
|
# Creating several User objects:
|
||||||
user1 = users_factory()
|
user1 = users_factory()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user