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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5cb8ce6e01a3cca2df893843489987645885b6f3
4
- data.tar.gz: 023f597d968c21b40dc1db1237c377c17326263b
3
+ metadata.gz: 482d1f4bc768f85dd4a285c294ed535a9633b15a
4
+ data.tar.gz: 05b5ce6f7d600f0b4307fa50fe193fe2612547b9
5
5
  SHA512:
6
- metadata.gz: e6ae48707d1beff5059ffe3aff5ba5f73e4e479dc156895ad17b549f72089e31662e0d2eebba68f6b385572692a787502088799e3bba796ef7a2ce99293faf39
7
- data.tar.gz: 0df16432e752a310a61dee8fd42e6560250daf4ac302f940f706dfc9d57520baf8178050ffaa53419ddb09e9ac275bc38943a9fe6b33cdc1106f555432ffacd9
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
@@ -1,3 +1,3 @@
1
1
  module IOC
2
- VERSION = "0.3.1"
2
+ VERSION = "0.4.1"
3
3
  end
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.3.1
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-01-31 00:00:00.000000000 Z
11
+ date: 2014-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler