From 90ff917267f24a37442b7f2375875ffefb71adc1 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 30 Mar 2015 15:56:46 +0300 Subject: [PATCH] Update README.md --- README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/README.md b/README.md index 7d6bad29..1cfdeeb4 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,32 @@ Current section describes main `Objects` entities and their interaction. Providers are strategies of accessing objects. +They describe how particular object need to be provided. For example: + +```python +from objects.providers import NewInstance +from objects.providers import Singleton + + +# NewInstance provider will create new instance of specified class on every call. + +new_object = NewInstance(object) + +object_1 = new_object() +object_2 = new_object() + +assert object_1 is not object_2 + +# Singleton provider will create new instance of specified class on first call, and return same instance on every next call. + +single_object = Singleton(object) + +single_object_1 = single_object() +single_object_2 = single_object() + +assert single_object_1 is single_object_2 +``` + ### Injections Injections are additional instructions, that are used for determining