Update static providers docs

This commit is contained in:
Roman Mogilatov 2015-09-02 18:16:25 +03:00
parent a7ca196ee0
commit a9eedc6760
2 changed files with 9 additions and 12 deletions

View File

@ -4,10 +4,10 @@ Static providers
Static providers are family of providers that return their values "as is".
There are four types of static providers:
- ``Class``
- ``Object``
- ``Function``
- ``Value``
- ``di.Class``
- ``di.Object``
- ``di.Function``
- ``di.Value``
All of them have the same behaviour, but usage of anyone is predicted by
readability and providing object's type.

View File

@ -1,23 +1,20 @@
"""`Static` providers example."""
from dependency_injector.providers import Class
from dependency_injector.providers import Object
from dependency_injector.providers import Function
from dependency_injector.providers import Value
import dependency_injector as di
# Provides class - `object`:
cls_provider = Class(object)
cls_provider = di.Class(object)
assert cls_provider() is object
# Provides object - `object()`:
object_provider = Object(object())
object_provider = di.Object(object())
assert isinstance(object_provider(), object)
# Provides function - `len`:
function_provider = Function(len)
function_provider = di.Function(len)
assert function_provider() is len
# Provides value - `123`:
value_provider = Value(123)
value_provider = di.Value(123)
assert value_provider() == 123