dependency_injection 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/dependency_injection/definition.rb +18 -18
- data/lib/dependency_injection/version.rb +1 -1
- data/test/dependency_injection/test_definition.rb +4 -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: eb8480e78fb38c546e3c81c90e1f6f9a1a5802e8
|
4
|
+
data.tar.gz: 54d44e720653e8410c041fc1329764d6cbbc2006
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 826b68d278823ec060007d8c631443ef9d1368b5573312c241c2969622d185d8e6b4047f07f42f9cfcb7b0dd5dcc18fbe285376ade582d8e28ecd003698b9293
|
7
|
+
data.tar.gz: 4aa1c43f77731c12307829b730dd0d2fd2af1a8fc344b816dd820ab24beab3d1e27ac844d2f4bb06875054b90c0a13f496619b34d37cda2bf8d573a7c440f7a0
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -87,27 +87,27 @@ module DependencyInjection
|
|
87
87
|
resolve_references(resolve_container_parameters(arguments))
|
88
88
|
end
|
89
89
|
|
90
|
-
def resolve_container_parameters(
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
90
|
+
def resolve_container_parameters(argument)
|
91
|
+
if argument.kind_of?(Array)
|
92
|
+
argument.map { |arg| resolve(arg) }
|
93
|
+
elsif /^%(?<parameter_name>.*)%$/ =~ argument
|
94
|
+
@container.parameters[parameter_name]
|
95
|
+
else
|
96
|
+
argument
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
|
-
def resolve_references(
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
100
|
+
def resolve_references(argument)
|
101
|
+
if argument.kind_of?(Array)
|
102
|
+
argument.map { |arg| resolve(arg) }
|
103
|
+
elsif /^@(?<reference_name>.*)/ =~ argument
|
104
|
+
reference_definition = @container.find(reference_name)
|
105
|
+
reference = reference_definition.object
|
106
|
+
raise ScopeWideningInjectionError if reference_definition.scope == :prototype && scope == :container
|
107
|
+
|
108
|
+
reference
|
109
|
+
else
|
110
|
+
argument
|
111
111
|
end
|
112
112
|
end
|
113
113
|
end
|
@@ -189,6 +189,10 @@ class TestDefinition < Minitest::Test
|
|
189
189
|
assert_equal(['first', 'value'], @definition.send(:resolve_container_parameters, %w(first %parameter%)))
|
190
190
|
end
|
191
191
|
|
192
|
+
def test_resolving_references_with_array
|
193
|
+
assert_equal(['first', ['second', 'third']], @definition.send(:resolve_references, ['first', ['second', 'third']]))
|
194
|
+
end
|
195
|
+
|
192
196
|
def test_resolving_references_without_references
|
193
197
|
assert_equal(%w(first second), @definition.send(:resolve_references, %w(first second)))
|
194
198
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dependency_injection
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Disneur
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|