ioc 4.0.0 → 4.1.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: 88f7a749eb3e62a7f4633a46b76fc0d353315588
4
- data.tar.gz: 23827f1f2cb06e3f27240287edaf5d5ce3ab890d
3
+ metadata.gz: beb7d05c11433d3fd20a45084e0c41ff64f166cf
4
+ data.tar.gz: cb699ee843c95a790b4af1b16d547f7d4e21ad79
5
5
  SHA512:
6
- metadata.gz: 1c72d08fb16c77a1c40145e4f05a828c370c2974fc5a6673f5b090bdbcf5be929139171ed3500aa40c8484317a7de0c16c8d95bb9f0444cf6b59feafb7082d55
7
- data.tar.gz: 5e59363962cd2c7823d71a1647eb32dd8d7a4a6e9fbc4fccce34479a15b9abd3b2e25e0b135458f895a62a4c9e440b78b78974185f7980a3d53687fb662d2483
6
+ metadata.gz: f0a1c1617334862a57ae5e65e86d8cd23ad7aaeae8b47b0b5f9ae5e3b450ddd4e16fa8999d055b9a227d3f630be94715424e3d0112ec0d663fc8e8543266d82e
7
+ data.tar.gz: 2f4aeb3e70503c3746ba63f5eb71870be9a17567be715ba4f091551d25cf9733e644ba290e62f753e8c41d7acc059e0bb5cc20e02dcc85b835e7e9d35f65fadb
data/ioc.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'ioc'
5
- spec.version = '4.0.0'
5
+ spec.version = '4.1.0'
6
6
  spec.authors = ['Erik Lott']
7
7
  spec.email = ['erik.lott@kodio.io']
8
8
  spec.summary = 'Minimal inversion of control container for Ruby'
data/lib/ioc/container.rb CHANGED
@@ -4,10 +4,12 @@ require "ioc/unresolvable_container"
4
4
 
5
5
  module IOC
6
6
  class Container
7
- def initialize(parent=UnresolvableContainer.new)
7
+ def initialize(parent=UnresolvableContainer.new, &block)
8
8
  @services = {}
9
9
  @cache = {}
10
10
  @parent = parent
11
+
12
+ self.instance_eval(&block) if block_given?
11
13
  end
12
14
 
13
15
  def register(service_name, klass=nil, &block)
@@ -102,8 +102,16 @@ describe IOC::Container do
102
102
  child_container.resolve(:myobject).must_equal(myobject)
103
103
  end
104
104
 
105
- def define_container(*args)
106
- IOC::Container.new(*args)
105
+ it "can be initialized with a block" do
106
+ myobject = "a string object"
107
+ container = define_container do
108
+ register(:myobject){|c| myobject }
109
+ end
110
+ container.resolve(:myobject).must_equal(myobject)
111
+ end
112
+
113
+ def define_container(*args, &block)
114
+ IOC::Container.new(*args, &block)
107
115
  end
108
116
 
109
117
  def define_class_with_engine_dependency
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ioc
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erik Lott