lazy_injector 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/Rakefile +3 -3
- data/examples/basics.rb +6 -1
- data/lazy_injector.gemspec +1 -1
- data/lib/lazy_injector.rb +2 -2
- data/lib/lazy_injector/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22b50e3c4abf27aa81ea7d2f7eb3b131decc1fef
|
4
|
+
data.tar.gz: 37054d770cd6373c9d1180a4c75af2ff783f9374
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25d022a4b0a868ee15fa8195401f5b3b33230426abddb9c40102efeacd3683b26ea91f0ab30d66aa3d81d538d106d631088b5f71de59d06ffb74a81a58ae7c07
|
7
|
+
data.tar.gz: 5bb9688c42bf8ef9d6422632b4802854f2b885405a78145cb6e2c2792db32d7dd4d05d7dbfda33c61cc218ab16f758fbbe447f3884f189fe8aa6d93ff0324291
|
data/README.md
CHANGED
data/Rakefile
CHANGED
data/examples/basics.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'lazy_injector'
|
2
2
|
require 'ostruct'
|
3
3
|
|
4
|
-
module
|
4
|
+
module Parts
|
5
5
|
include LazyInjector
|
6
6
|
|
7
7
|
register(:wheel_factory) { Struct.new(:axle, :side) }
|
@@ -16,6 +16,11 @@ module Dependencies
|
|
16
16
|
end
|
17
17
|
|
18
18
|
register(:engine) { OpenStruct.new }
|
19
|
+
end
|
20
|
+
|
21
|
+
module Dependencies
|
22
|
+
include LazyInjector
|
23
|
+
include Parts
|
19
24
|
|
20
25
|
register :car do
|
21
26
|
OpenStruct.new(engine: engine, wheels: wheels)
|
data/lazy_injector.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.require_paths = ['lib']
|
24
24
|
|
25
25
|
spec.add_development_dependency 'bundler', '~> 1.11'
|
26
|
-
spec.add_development_dependency
|
26
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
27
27
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
28
28
|
spec.add_development_dependency 'rubocop'
|
29
29
|
end
|
data/lib/lazy_injector.rb
CHANGED
@@ -6,14 +6,14 @@ module LazyInjector
|
|
6
6
|
end
|
7
7
|
|
8
8
|
module ClassMethods
|
9
|
-
def register(name)
|
9
|
+
def register(name, &block)
|
10
10
|
define_method name do
|
11
11
|
@lazy_injector ||= {}
|
12
12
|
|
13
13
|
if @lazy_injector.key?(name)
|
14
14
|
@lazy_injector[name]
|
15
15
|
else
|
16
|
-
@lazy_injector[name] =
|
16
|
+
@lazy_injector[name] = block and instance_eval(&block)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|