ioc 0.3.1 → 0.4.1
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 +6 -0
- data/lib/ioc/version.rb +1 -1
- data/spec/ioc_spec.rb +7 -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: 482d1f4bc768f85dd4a285c294ed535a9633b15a
|
4
|
+
data.tar.gz: 05b5ce6f7d600f0b4307fa50fe193fe2612547b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1ed059dc38251223cf6d264090760bb1dcbcc76988456fd1753ea7cb69a61fbbea01c51211edb3230e3b0154a386d2d8635bd1938de2bf57bc300f337822861
|
7
|
+
data.tar.gz: 262520201231d3db03c8f1e8d62d51c78b824cd432552fac91f5274ed7995f9ca84b2b41f6197457a5dd6ec1aeb6c51c010ff25bb61c0e91a1a78961de9b55e8
|
data/lib/ioc/container.rb
CHANGED
@@ -21,6 +21,12 @@ 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
|
24
30
|
end
|
25
31
|
|
26
32
|
def resolve(name)
|
data/lib/ioc/version.rb
CHANGED
data/spec/ioc_spec.rb
CHANGED
@@ -206,6 +206,13 @@ describe IOC::Container do
|
|
206
206
|
container.resolve(:myobj).must_equal('I was resolved')
|
207
207
|
end
|
208
208
|
|
209
|
+
it 'can use method to resolve service' do
|
210
|
+
container = new_container
|
211
|
+
my_object = stub
|
212
|
+
container.register(:myobj, my_object, :as => :instance)
|
213
|
+
container.myobj.must_equal(my_object)
|
214
|
+
end
|
215
|
+
|
209
216
|
def new_container(*args)
|
210
217
|
IOC::Container.new(*args)
|
211
218
|
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.4.1
|
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-
|
11
|
+
date: 2014-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|