ioc 0.4.1 → 0.5.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 +4 -6
- data/lib/ioc/version.rb +1 -1
- data/spec/ioc_spec.rb +4 -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: cbd6320c35da7137365876a79de6e2840f7a1da1
|
4
|
+
data.tar.gz: 35e6e4aafc8e187aa80f088b0c190ceed34f135b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d441de52d56f472d6808a967f9c9a3906026a1b63747460525801696dde49e5b48b7b862c71c9f872ce825260c3c08d8dac54d5d6aeac711318d13788fb87282
|
7
|
+
data.tar.gz: db57125c9b27d697938839cdc244128fd3b7a3153178a8517b06ec3ecb5ff1415c16976135e7c24ab8f74a922026eed7252d92776dbcffd54c454debd350643b
|
data/lib/ioc/container.rb
CHANGED
@@ -21,18 +21,16 @@ module IOC
|
|
21
21
|
def register(name, object, options={})
|
22
22
|
raise(DuplicateRegistration, "Service '#{name}' has already been registered") if @resolvers.key?(name)
|
23
23
|
@resolvers[name] = @resolver_factory.new_instance(name, object, self, options)
|
24
|
-
|
25
|
-
instance_eval <<-EOT, __FILE__, __LINE__ + 1
|
26
|
-
def #{name} # def user_repository
|
27
|
-
resolve(:#{name}) # resolve(:user_repository)
|
28
|
-
end # end
|
29
|
-
EOT
|
30
24
|
end
|
31
25
|
|
32
26
|
def resolve(name)
|
33
27
|
resolver(name).resolve(@cache)
|
34
28
|
end
|
35
29
|
|
30
|
+
def [](key)
|
31
|
+
resolve(key)
|
32
|
+
end
|
33
|
+
|
36
34
|
def resolver(name)
|
37
35
|
@resolvers[name] || @parent.resolver(name)
|
38
36
|
end
|
data/lib/ioc/version.rb
CHANGED
data/spec/ioc_spec.rb
CHANGED
@@ -206,11 +206,11 @@ describe IOC::Container do
|
|
206
206
|
container.resolve(:myobj).must_equal('I was resolved')
|
207
207
|
end
|
208
208
|
|
209
|
-
it '
|
209
|
+
it 'supports resolving via hash syntax' do
|
210
210
|
container = new_container
|
211
|
-
|
212
|
-
container.register(:
|
213
|
-
container.
|
211
|
+
myclass = new_class
|
212
|
+
container.register(:myclass, myclass)
|
213
|
+
container[:myclass].must_be_instance_of(myclass)
|
214
214
|
end
|
215
215
|
|
216
216
|
def new_container(*args)
|
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.5.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-02-
|
11
|
+
date: 2014-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|