README.md in smart_container-0.2.0 vs README.md in smart_container-0.3.0
- old
+ new
@@ -25,22 +25,22 @@
## Synopsis (demo)
```ruby
class Container < SmartCore::Container
namespace(:database) do # support for namespaces
- register(:resolver) { SomeDatabaseResolver.new } # dependency registration
+ register(:resolver, memoize: true) { SomeDatabaseResolver.new } # dependency registration
namespace(:cache) do # support for nested naespaces
- register(:memcached) { MemcachedClient.new }
- register(:redis) { RedisClient.new }
+ register(:memcached, memoize: true) { MemcachedClient.new }
+ register(:redis, memoize: true) { RedisClient.new }
end
end
# root dependencies
- register(:logger) { Logger.new(STDOUT) }
+ register(:logger, memoize: true) { Logger.new(STDOUT) }
- # do not memoize registered object
- register(:random, memoize: false) { rand(1000) }
+ # dependencies are not memoized by default (memoize: false)
+ register(:random) { rand(1000) }
end
container = Container.new # create container instance
container['database.resolver'] # => #<SomeDatabaseResolver:0x00007f0f0f1d6332>