ioc 0.2.0 → 0.3.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
  SHA1:
3
- metadata.gz: ac7c1b4bc6cd15d943d365d4ede0d87fb600d879
4
- data.tar.gz: 0ca2873cc691d49b5897308d0c2253661b001584
3
+ metadata.gz: 5f9b4ded444c163bcc5b3347c651f12f5d9911f4
4
+ data.tar.gz: 8ff0dc2532edf5c9a02f16e977384203aa343b38
5
5
  SHA512:
6
- metadata.gz: aa6c8d3754601bb4c634e014fae5f4d546f4e6c7de22f360b326a3048519a8e3bd140abc5b46d78bba15f77bc7bfed841939fa36550485067de295cd6ba7ce7a
7
- data.tar.gz: 4c053957ca8bb28fea04d68f4c166e42a0dcbf234ebfa1d9d3b7da662cda68b3c259e526786d422cb8ebb109bca237bc2411f06cfe38369cb4620ff9364e084f
6
+ metadata.gz: b447c98ba611bd3d48ae34a0e6f40a7375557752d93439c4619f1bafbb0368ac1a5fbc5ec56d9fe669db1b1014d5d11e769c2f3b1cd6e67e86e50c45d905f980
7
+ data.tar.gz: 826f0ad29d6b2432ce4057539b4ad13af6466710b1b8f7cde86338b6b8c4e70073884f6e64dce234f77c6f2ba132119b195e7dc2b78855f72e86a4b4175ab4d6
@@ -1,5 +1,13 @@
1
1
  module IOC
2
2
  class Container
3
+
4
+ def self.install(*installers)
5
+ [*installers].inject(new) do |container, installer|
6
+ installer.install(container)
7
+ container
8
+ end
9
+ end
10
+
3
11
  def initialize(parent=Container, resolver_factory=ResolverFactory)
4
12
  @resolver_factory = resolver_factory
5
13
  @resolvers = {}
@@ -1,3 +1,3 @@
1
1
  module IOC
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -195,6 +195,17 @@ describe IOC::Container do
195
195
  end
196
196
  end
197
197
 
198
+ it 'can register components using an installer' do
199
+ installer_class = Class.new do
200
+ def self.install(c)
201
+ c.register(:myobj, 'I was resolved', :as => :instance)
202
+ end
203
+ end
204
+
205
+ container = IOC::Container.install(installer_class)
206
+ container.resolve(:myobj).must_equal('I was resolved')
207
+ end
208
+
198
209
  def new_container(*args)
199
210
  IOC::Container.new(*args)
200
211
  end
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: 0.2.0
4
+ version: 0.3.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: 2014-01-29 00:00:00.000000000 Z
11
+ date: 2014-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler