ioc 6.1.0 → 6.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/ioc.gemspec +1 -1
  3. data/lib/ioc.rb +6 -2
  4. data/spec/ioc_spec.rb +10 -4
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5d74cd8f28348bde6d237602eab9f19a35483152
4
- data.tar.gz: fe5e748bfbb204763e1285487d0601c59c5d3dcd
3
+ metadata.gz: 298698e6855ba0747c2e2cf86289b06486adef52
4
+ data.tar.gz: 2d0bd0acb98c8cc6084d847c46a1a8fca9fcf301
5
5
  SHA512:
6
- metadata.gz: c1b6862816c763988e82a8d484205fa8ed5fa233fa9ca8d77fbdc8f1b4e1c28dfb8c64df5f877b2e22c7ea2b4746b531ac6b3bfc84f67bbd4abcb955b125dc0e
7
- data.tar.gz: f7f162920ae8bfed59bcf3cd1656cc0b8236fe2f434ba9c9126ba6d77a9f8c8712f921fa72c129bd8984751cfc976cdae6987bf71c7a5c4d38216da8b4c98d48
6
+ metadata.gz: 803e90589929c05c4f8abc1c319504d7ea9a14c145b00d5b1569942b25c57a99471cecd029b324d7f479584848350c48ad9397ad45e55a981559f8b0bbd9f8cc
7
+ data.tar.gz: 08124d69e007ca26e12a1befb10c29f7415b4ac667b10d071d8a55dd1d9ca42759b21fa2b694d09cea2a80b838ac06c74bac2bd83095a0171092782a499b2efd
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "ioc"
5
- spec.version = "6.1.0"
5
+ spec.version = "6.2.0"
6
6
  spec.authors = ["Erik Lott"]
7
7
  spec.email = ["erik.lott@kodio.io"]
8
8
  spec.summary = "Minimal dependency injection container for Ruby"
data/lib/ioc.rb CHANGED
@@ -30,10 +30,14 @@ module IOC
30
30
  end
31
31
  end
32
32
 
33
- def each_type(klass)
33
+ def resolve_by_type(type)
34
+ resolved_services = []
34
35
  @services.each do |key, service|
35
- yield(key, service) if service <= klass
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
@@ -44,13 +44,19 @@ describe IOC do
44
44
  container.resolve(:myobject).must_equal(myobject)
45
45
  end
46
46
 
47
- it "iterate through registrants by type" do
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
- services = {}
52
- container.each_type(PropulsionFixture) {|key, service| services[key] = service}
53
- services.must_equal(:engine => EngineFixture, :motor => MotorFixture)
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.1.0
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-29 00:00:00.000000000 Z
11
+ date: 2015-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler