smart_container 0.5.0 → 0.6.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: 92746ed446b181dc165a597563edc69b62b41550974023342c4693f2c17dee6a
4
- data.tar.gz: 1cf3862c40c1044510a11e09f19df542a8d0b3a255bd0df5593ad9c531b9f10b
3
+ metadata.gz: 45dcb7eb69c563a3d73ba1b232b8030eb527b82c29601b62948aa37e6d54e3d6
4
+ data.tar.gz: 0f2cccd96c4a43a9912f3d97e0d7b3ca3f61492ec098b0c8337994e7eee87cc4
5
5
  SHA512:
6
- metadata.gz: ec6db288f98f769d0bbe96dd4d35186d1a199f6e046edf1de83a50c4b76149366c94a7c172a005378be88c8e8503436b9dad7e2518bcbae1de939b2a37204600
7
- data.tar.gz: 9124de765215847cb7bd135a19524043652b9f9d7580027106a43cc6fa8f61a3bfd22c982cf07b1f46ea196b6fdae978d0973682a9c24511eb679d7c310b33a7
6
+ metadata.gz: e41e917b41e5f0ae33bd321d20abffe1614ac04b19bff4e91ce9fe078e1d462cd7bb91f1fc3cae1c09aa5240e68f53bf74889df413ad03bc1f940baf8e90361d
7
+ data.tar.gz: d306a3c1076de3f4e460abf09915e0f2d4088095fd4e4d61b3f0808547f966af256673ed87a0c5ef28253c5d56e1de796d3f03fff019b66208bb535edfdb4ed4
@@ -1,6 +1,12 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [0.6.0] - 2020-01-12
5
+ ### Added
6
+ - Missing memoization flag `:memoize` for runtime-based dependency registration:
7
+ - `memoize: false` by default;
8
+ - signature: `SmartCore::Container#register(dependency_name, memoize: false, &dependency)`
9
+
4
10
  ## [0.5.0] - 2020-01-07
5
11
  ### Added
6
12
  - Key predicates (`#key?(key)`, `#dependency?(path, memoized: nil/true/false)`, `#namespace?(path)`);
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- smart_container (0.4.0)
4
+ smart_container (0.6.0)
5
5
  smart_engine (~> 0.2)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -74,10 +74,10 @@ container.fetch('database.resolver') # => #<SomeDatabaseResolver:0x00007f0f0f1d6
74
74
 
75
75
  ```ruby
76
76
  container.namespace(:api) do
77
- register(:provider) { GoogleProvider }
77
+ register(:provider) { GoogleProvider } # without memoization
78
78
  end
79
79
 
80
- container.register('game_api') { 'overwatch' }
80
+ container.register('game_api', memoize: true) { 'overwatch' } # with memoization
81
81
 
82
82
  container['api.provider'] # => GoogleProvider
83
83
  container['game_api'] # => 'overwatch'
@@ -47,8 +47,14 @@ module SmartCore
47
47
  #
48
48
  # @api public
49
49
  # @sicne 0.1.0
50
- def register(dependency_name, &dependency_definition)
51
- thread_safe { registry.register_dependency(dependency_name, &dependency_definition) }
50
+ def register(
51
+ dependency_name,
52
+ memoize: SmartCore::Container::Registry::DEFAULT_MEMOIZATION_BEHAVIOR,
53
+ &dependency_definition
54
+ )
55
+ thread_safe do
56
+ registry.register_dependency(dependency_name, memoize: memoize, &dependency_definition)
57
+ end
52
58
  end
53
59
 
54
60
  # @param namespace_name [String, Symbol]
@@ -36,7 +36,7 @@ module SmartCore::Container::DefinitionDSL::Commands::Definition
36
36
  # @since 0.1.0
37
37
  # @version 0.2.0
38
38
  def call(registry)
39
- registry.register_dependency(dependency_name, memoize, &dependency_definition)
39
+ registry.register_dependency(dependency_name, memoize: memoize, &dependency_definition)
40
40
  end
41
41
 
42
42
  # @return [SmartCore::Container::DefinitionDSL::Commands::Definition::Register]
@@ -57,7 +57,7 @@ class SmartCore::Container::Registry
57
57
  # @api private
58
58
  # @since 0.1.0
59
59
  # @version 0.3.0
60
- def register_dependency(name, memoize = DEFAULT_MEMOIZATION_BEHAVIOR, &dependency_definition)
60
+ def register_dependency(name, memoize: DEFAULT_MEMOIZATION_BEHAVIOR, &dependency_definition)
61
61
  thread_safe { add_dependency(name, dependency_definition, memoize) }
62
62
  end
63
63
 
@@ -4,7 +4,7 @@ module SmartCore
4
4
  class Container
5
5
  # @api public
6
6
  # @since 0.1.0
7
- # @version 0.5.0
8
- VERSION = '0.5.0'
7
+ # @version 0.6.0
8
+ VERSION = '0.6.0'
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_container
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rustam Ibragimov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-07 00:00:00.000000000 Z
11
+ date: 2020-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: smart_engine