ioc 6.1.0 → 6.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ioc.gemspec +1 -1
- data/lib/ioc.rb +6 -2
- data/spec/ioc_spec.rb +10 -4
- 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: 298698e6855ba0747c2e2cf86289b06486adef52
|
4
|
+
data.tar.gz: 2d0bd0acb98c8cc6084d847c46a1a8fca9fcf301
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 803e90589929c05c4f8abc1c319504d7ea9a14c145b00d5b1569942b25c57a99471cecd029b324d7f479584848350c48ad9397ad45e55a981559f8b0bbd9f8cc
|
7
|
+
data.tar.gz: 08124d69e007ca26e12a1befb10c29f7415b4ac667b10d071d8a55dd1d9ca42759b21fa2b694d09cea2a80b838ac06c74bac2bd83095a0171092782a499b2efd
|
data/ioc.gemspec
CHANGED
data/lib/ioc.rb
CHANGED
@@ -30,10 +30,14 @@ module IOC
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
def
|
33
|
+
def resolve_by_type(type)
|
34
|
+
resolved_services = []
|
34
35
|
@services.each do |key, service|
|
35
|
-
|
36
|
+
if service <= type
|
37
|
+
resolved_services << resolve(key)
|
38
|
+
end
|
36
39
|
end
|
40
|
+
resolved_services
|
37
41
|
end
|
38
42
|
|
39
43
|
def release
|
data/spec/ioc_spec.rb
CHANGED
@@ -44,13 +44,19 @@ describe IOC do
|
|
44
44
|
container.resolve(:myobject).must_equal(myobject)
|
45
45
|
end
|
46
46
|
|
47
|
-
it "
|
47
|
+
it "can resolve services by type" do
|
48
48
|
container = IOC::Container.new
|
49
49
|
container.register(:engine, EngineFixture)
|
50
50
|
container.register(:motor, MotorFixture)
|
51
|
-
|
52
|
-
container.
|
53
|
-
|
51
|
+
|
52
|
+
result = container.resolve_by_type(PropulsionFixture)
|
53
|
+
|
54
|
+
expected = [
|
55
|
+
container.resolve(:engine),
|
56
|
+
container.resolve(:motor)
|
57
|
+
]
|
58
|
+
|
59
|
+
result.must_equal(expected)
|
54
60
|
end
|
55
61
|
|
56
62
|
it "complains when resolving unknown service" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ioc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.
|
4
|
+
version: 6.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erik Lott
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|