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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b458f920f5b8f2c818570729207cb4db1c537a8c
4
- data.tar.gz: 9a83107daf4cf6f131d69a035e7cb8f16ff655fb
3
+ metadata.gz: eb8480e78fb38c546e3c81c90e1f6f9a1a5802e8
4
+ data.tar.gz: 54d44e720653e8410c041fc1329764d6cbbc2006
5
5
  SHA512:
6
- metadata.gz: 2f92f31ffdbec7ff33b625e16f39176590fd1cf5bc304bd3f8103a85f7dfa026f2de237ae5aee01b0c11de72f8805be4213fcfdd240f7b51cad1abdfda57b2e6
7
- data.tar.gz: c881904dba9631b7c2121b007d0feee0dfe0e2a694bf942c3fc441b4fa239707a0d8c5502fb1d94d6982afd090d34c1ffcf80868e5eec4c714988018869113fd
6
+ metadata.gz: 826b68d278823ec060007d8c631443ef9d1368b5573312c241c2969622d185d8e6b4047f07f42f9cfcb7b0dd5dcc18fbe285376ade582d8e28ecd003698b9293
7
+ data.tar.gz: 4aa1c43f77731c12307829b730dd0d2fd2af1a8fc344b816dd820ab24beab3d1e27ac844d2f4bb06875054b90c0a13f496619b34d37cda2bf8d573a7c440f7a0
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.4.2 (2014-03-16)
2
+
3
+ * Fix an error when a service takes an arrays as parameter
4
+
1
5
  # 0.4.1 (2014-02-23)
2
6
 
3
7
  * Nothing adding/removed. Just fix the Gemfile.lock
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dependency_injection (0.4.1)
4
+ dependency_injection (0.4.2)
5
5
  activesupport
6
6
 
7
7
  GEM
@@ -87,27 +87,27 @@ module DependencyInjection
87
87
  resolve_references(resolve_container_parameters(arguments))
88
88
  end
89
89
 
90
- def resolve_container_parameters(arguments)
91
- arguments.map do |argument|
92
- if /^%(?<parameter_name>.*)%$/ =~ argument
93
- @container.parameters[parameter_name]
94
- else
95
- argument
96
- end
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(arguments)
101
- arguments.map do |argument|
102
- if /^@(?<reference_name>.*)/ =~ argument
103
- reference_definition = @container.find(reference_name)
104
- reference = reference_definition.object
105
- raise ScopeWideningInjectionError if reference_definition.scope == :prototype && scope == :container
106
-
107
- reference
108
- else
109
- argument
110
- end
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
@@ -1,3 +1,3 @@
1
1
  module DependencyInjection
2
- VERSION = '0.4.1'
2
+ VERSION = '0.4.2'
3
3
  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.1
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-02-23 00:00:00.000000000 Z
11
+ date: 2014-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport