README.md in smart_container-0.1.0 vs README.md in smart_container-0.2.0
- old
+ new
@@ -20,9 +20,42 @@
require 'smart_core/container'
```
---
+## Synopsis (demo)
+
+```ruby
+class Container < SmartCore::Container
+ namespace(:database) do # support for namespaces
+ register(:resolver) { SomeDatabaseResolver.new } # dependency registration
+
+ namespace(:cache) do # support for nested naespaces
+ register(:memcached) { MemcachedClient.new }
+ register(:redis) { RedisClient.new }
+ end
+ end
+
+ # root dependencies
+ register(:logger) { Logger.new(STDOUT) }
+
+ # do not memoize registered object
+ register(:random, memoize: false) { rand(1000) }
+end
+
+container = Container.new # create container instance
+
+container['database.resolver'] # => #<SomeDatabaseResolver:0x00007f0f0f1d6332>
+container['database.cache.redis'] # => #<RedisClient:0x00007f0f0f1d0158>
+container['logger'] # => #<Logger:0x00007f5f0f2f0158>
+
+# non-memoized dependency
+container['random'] # => 352
+container['random'] # => 57
+```
+
+---
+
## Contributing
- Fork it ( https://github.com/smart-rb/smart_container/fork )
- Create your feature branch (`git checkout -b feature/my-new-feature`)
- Commit your changes (`git commit -am '[feature_context] Add some feature'`)