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 +4 -4
- data/lib/dry/container/mixin.rb +15 -2
- data/lib/dry/container/version.rb +1 -1
- data/spec/support/shared_examples/container.rb +15 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18b93873ebbb6d027bc713b5f3af823f1db50800
|
4
|
+
data.tar.gz: 07c73e06100d4b7c8cde5d2d6bc4446b46ff552f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c8a18232ff3e895eefa1e6b3fe046f255d9add144a7aa302f431e92d81cceae292cc6b90a3d9157b202b6bd50eb1bfc37686920731a626204f3b49792183852
|
7
|
+
data.tar.gz: b5376428867106db4b3b70cd33e07a035be1a46ce2ae5be7fc93085e5b08efbae06dd7f6db1dac33fcd743cb23c81169f86360c3ec6397725fabd8e45a950282
|
data/lib/dry/container/mixin.rb
CHANGED
@@ -35,7 +35,7 @@ module Dry
|
|
35
35
|
setting :resolver, ::Dry::Container::Resolver.new
|
36
36
|
setting :namespace_separator, '.'
|
37
37
|
|
38
|
-
@_container = ::ThreadSafe::
|
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::
|
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
|
@@ -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.
|
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-
|
11
|
+
date: 2015-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thread_safe
|