smart_container 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8724a62bc6365606a5b796bac2899c5ddba96c179548878f12e324291b6862a3
4
- data.tar.gz: 769c81de665be07979bbeb8026398ff6cf6e8885159cbe6ab1aff52d07a64095
3
+ metadata.gz: 919cbfa847aa6931a64cf70c07269a0883ac0b5f47e9b84243854b0ea626f49e
4
+ data.tar.gz: b9fcfbf5060a973bf1aa8e81d8a78cbdabf243e585dea583e64904e698c094dc
5
5
  SHA512:
6
- metadata.gz: b1f138811f9b345b2f735b4f90e06d44ef83b955358e78b786becb9e2d73144de113cbfc0b08d765c245a7c1a4889bba8f5c3ed63219f28fa312554f8834d1ae
7
- data.tar.gz: 69da3a3c4ac8b5d34243a617dff6614654a9c116ef7270f7f313127dafe973a2d102143df21fcad222bb9d94499606f983835b74e711a9c823934c58c8bc42a2
6
+ metadata.gz: 282c7f32da7c8029518b72f94b1047ed71046db44b0e18c9eef2557158bbf3ad97bb5ed658af9a836105964175fa2fd5a5b6ddb0568700b39ed471e7b6ec4c28
7
+ data.tar.gz: bfabb455faa37954f0700d2f910e6de93ed4194bb9bb63d45918af7e81de92a5f07f3edf503c922a363d682d6a227cad64a5e5f4c53b355db0b8018757397bb4
@@ -1,25 +1,16 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
- ## [0.2.0] - 202-01-05
4
+ ## [0.3.0] - 2020-01-05
5
+ ### Changed
6
+ - Dependency resolving is not memoized by default (previously: totally memoized 😱);
7
+
8
+ ## [0.2.0] - 2020-01-05
5
9
  ### Changed
6
10
  - (Private API (`SmartCore::Container::RegistryBuilder`)) improved semantics:
7
11
  - `build_state` is renamed to `initialise`;
8
12
  - `build_definitions` is renamed to `define`;
9
- - (Public API) Support for memoized dependencies (all dependencies are memoized by default)
10
- ```ruby
11
- class MyContainer < SmartCore::Container
12
- namespace(:some_naespace) do
13
- # memoized by default
14
- register(:random_number) { rand(1000) }
15
- # explicit memoization
16
- register(:random_number, memoized: true) { rand(1000) }
17
-
18
- # register non-memoizable dependency
19
- register(:random_number, memoized: false) { rand(1000) }
20
- end
21
- end
22
- ```
13
+ - (Public API) Support for memoized dependencies (all dependencies are memoized by default);
23
14
 
24
15
  ## [0.1.0] - 2020-01-02
25
16
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- smart_container (0.2.0)
4
+ smart_container (0.3.0)
5
5
  smart_engine (~> 0.2)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -27,19 +27,19 @@ require 'smart_core/container'
27
27
  ```ruby
28
28
  class Container < SmartCore::Container
29
29
  namespace(:database) do # support for namespaces
30
- register(:resolver) { SomeDatabaseResolver.new } # dependency registration
30
+ register(:resolver, memoize: true) { SomeDatabaseResolver.new } # dependency registration
31
31
 
32
32
  namespace(:cache) do # support for nested naespaces
33
- register(:memcached) { MemcachedClient.new }
34
- register(:redis) { RedisClient.new }
33
+ register(:memcached, memoize: true) { MemcachedClient.new }
34
+ register(:redis, memoize: true) { RedisClient.new }
35
35
  end
36
36
  end
37
37
 
38
38
  # root dependencies
39
- register(:logger) { Logger.new(STDOUT) }
39
+ register(:logger, memoize: true) { Logger.new(STDOUT) }
40
40
 
41
- # do not memoize registered object
42
- register(:random, memoize: false) { rand(1000) }
41
+ # dependencies are not memoized by default (memoize: false)
42
+ register(:random) { rand(1000) }
43
43
  end
44
44
 
45
45
  container = Container.new # create container instance
@@ -69,8 +69,12 @@ class SmartCore::Container
69
69
  #
70
70
  # @api public
71
71
  # @since 0.1.0
72
- # @version 0.2.0
73
- def register(dependency_name, memoize: true, &dependency_definition)
72
+ # @version 0.3.0
73
+ def register(
74
+ dependency_name,
75
+ memoize: SmartCore::Container::Registry::DEFAULT_MEMOIZATION_BEHAVIOR,
76
+ &dependency_definition
77
+ )
74
78
  @__container_definition_lock__.thread_safe do
75
79
  DependencyCompatability::Definition.prevent_namespace_overlap!(self, dependency_name)
76
80
 
@@ -7,6 +7,12 @@ class SmartCore::Container::Registry
7
7
  # @since 0.1.0
8
8
  include Enumerable
9
9
 
10
+ # @return [Boolean]
11
+ #
12
+ # @api private
13
+ # @since 0.3.0
14
+ DEFAULT_MEMOIZATION_BEHAVIOR = false
15
+
10
16
  # @return [Hash<Symbol,SmartCore::Container::Entity>]
11
17
  #
12
18
  # @api private
@@ -38,8 +44,8 @@ class SmartCore::Container::Registry
38
44
  #
39
45
  # @api private
40
46
  # @since 0.1.0
41
- # @version 0.2.0
42
- def register_dependency(name, memoize = true, &dependency_definition)
47
+ # @version 0.3.0
48
+ def register_dependency(name, memoize = DEFAULT_MEMOIZATION_BEHAVIOR, &dependency_definition)
43
49
  thread_safe { add_dependency(name, dependency_definition, memoize) }
44
50
  end
45
51
 
@@ -4,7 +4,7 @@ module SmartCore
4
4
  class Container
5
5
  # @api public
6
6
  # @since 0.1.0
7
- # @version 0.2.0
8
- VERSION = '0.2.0'
7
+ # @version 0.3.0
8
+ VERSION = '0.3.0'
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_container
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rustam Ibragimov