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 +4 -4
- data/lib/ioc/container.rb +8 -0
- data/lib/ioc/version.rb +1 -1
- data/spec/ioc_spec.rb +11 -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: 5f9b4ded444c163bcc5b3347c651f12f5d9911f4
|
4
|
+
data.tar.gz: 8ff0dc2532edf5c9a02f16e977384203aa343b38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b447c98ba611bd3d48ae34a0e6f40a7375557752d93439c4619f1bafbb0368ac1a5fbc5ec56d9fe669db1b1014d5d11e769c2f3b1cd6e67e86e50c45d905f980
|
7
|
+
data.tar.gz: 826f0ad29d6b2432ce4057539b4ad13af6466710b1b8f7cde86338b6b8c4e70073884f6e64dce234f77c6f2ba132119b195e7dc2b78855f72e86a4b4175ab4d6
|
data/lib/ioc/container.rb
CHANGED
@@ -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 = {}
|
data/lib/ioc/version.rb
CHANGED
data/spec/ioc_spec.rb
CHANGED
@@ -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.
|
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-
|
11
|
+
date: 2014-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|