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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 482d1f4bc768f85dd4a285c294ed535a9633b15a
4
- data.tar.gz: 05b5ce6f7d600f0b4307fa50fe193fe2612547b9
3
+ metadata.gz: cbd6320c35da7137365876a79de6e2840f7a1da1
4
+ data.tar.gz: 35e6e4aafc8e187aa80f088b0c190ceed34f135b
5
5
  SHA512:
6
- metadata.gz: d1ed059dc38251223cf6d264090760bb1dcbcc76988456fd1753ea7cb69a61fbbea01c51211edb3230e3b0154a386d2d8635bd1938de2bf57bc300f337822861
7
- data.tar.gz: 262520201231d3db03c8f1e8d62d51c78b824cd432552fac91f5274ed7995f9ca84b2b41f6197457a5dd6ec1aeb6c51c010ff25bb61c0e91a1a78961de9b55e8
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
@@ -1,3 +1,3 @@
1
1
  module IOC
2
- VERSION = "0.4.1"
2
+ VERSION = "0.5.0"
3
3
  end
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 'can use method to resolve service' do
209
+ it 'supports resolving via hash syntax' do
210
210
  container = new_container
211
- my_object = stub
212
- container.register(:myobj, my_object, :as => :instance)
213
- container.myobj.must_equal(my_object)
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.1
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-07 00:00:00.000000000 Z
11
+ date: 2014-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler