dry-container 0.2.5 → 0.2.6

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
  SHA1:
3
- metadata.gz: d052fd82bb7597ea5b8c8b35a2c26b4900f16b02
4
- data.tar.gz: 47681932e60338aa93f70417de441d8bc21f52d7
3
+ metadata.gz: 18b93873ebbb6d027bc713b5f3af823f1db50800
4
+ data.tar.gz: 07c73e06100d4b7c8cde5d2d6bc4446b46ff552f
5
5
  SHA512:
6
- metadata.gz: 6ae27a601b7e9ff4574761c43de2328d9ce58c467cd121ef9509b66977a1e171894f3694a4bb8e0308428fc6d33b37519b03ccdac598d9f9b1c142e2fa5409e3
7
- data.tar.gz: ff561063839573816a19f1a96a813dda03bb2eea833c7d964c9b2725e79f2047994f72fe1cb05638c0b9c53e9faba56762e78345667eaa2c1331f42354dc1035
6
+ metadata.gz: 0c8a18232ff3e895eefa1e6b3fe046f255d9add144a7aa302f431e92d81cceae292cc6b90a3d9157b202b6bd50eb1bfc37686920731a626204f3b49792183852
7
+ data.tar.gz: b5376428867106db4b3b70cd33e07a035be1a46ce2ae5be7fc93085e5b08efbae06dd7f6db1dac33fcd743cb23c81169f86360c3ec6397725fabd8e45a950282
@@ -35,7 +35,7 @@ module Dry
35
35
  setting :resolver, ::Dry::Container::Resolver.new
36
36
  setting :namespace_separator, '.'
37
37
 
38
- @_container = ::ThreadSafe::Cache.new
38
+ @_container = ::ThreadSafe::Hash.new
39
39
 
40
40
  def self.inherited(subclass)
41
41
  subclass.instance_variable_set(:@_container, @_container)
@@ -56,7 +56,7 @@ module Dry
56
56
  attr_reader :_container
57
57
 
58
58
  def initialize(*args, &block)
59
- @_container = ::ThreadSafe::Cache.new
59
+ @_container = ::ThreadSafe::Hash.new
60
60
  super(*args, &block)
61
61
  end
62
62
 
@@ -107,6 +107,19 @@ module Dry
107
107
  end
108
108
  alias_method :[], :resolve
109
109
 
110
+ # Merge in the items of the other container
111
+ #
112
+ # @param [Dry::Container] other
113
+ # The other container to merge in
114
+ #
115
+ # @return [Dry::Container::Mixin] self
116
+ #
117
+ # @api public
118
+ def merge(other)
119
+ _container.merge!(other._container)
120
+ self
121
+ end
122
+
110
123
  # Check whether an items is registered under the given key
111
124
  #
112
125
  # @param [Mixed] key
@@ -1,6 +1,6 @@
1
1
  module Dry
2
2
  class Container
3
3
  # @api public
4
- VERSION = '0.2.5'.freeze
4
+ VERSION = '0.2.6'.freeze
5
5
  end
6
6
  end
@@ -214,6 +214,21 @@ shared_examples 'a container' do
214
214
  end
215
215
  end
216
216
 
217
+ describe '#merge' do
218
+ let(:key) { :key }
219
+ let(:other) { Dry::Container.new }
220
+
221
+ before do
222
+ other.register(key) { :item }
223
+ end
224
+
225
+ subject! { container.merge(other) }
226
+
227
+ it { expect(container.key?(key)).to be true }
228
+ it { expect(container.resolve(key)).to be(:item) }
229
+ it { expect(container[key]).to be(:item) }
230
+ end
231
+
217
232
  describe 'namespace' do
218
233
  context 'when block does not take arguments' do
219
234
  before do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry-container
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Holland
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-12 00:00:00.000000000 Z
11
+ date: 2015-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thread_safe