scorpion-ioc 0.6.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +144 -30
- data/Gemfile +17 -13
- data/README.md +24 -69
- data/Rakefile +12 -0
- data/app/README +1 -0
- data/bin/rspec +2 -1
- data/config.ru +2 -2
- data/config/environment.rb +1 -0
- data/lib/scorpion-ioc.rb +3 -1
- data/lib/scorpion.rb +32 -45
- data/lib/scorpion/attribute.rb +14 -34
- data/lib/scorpion/attribute_set.rb +11 -13
- data/lib/scorpion/chain_hunter.rb +4 -4
- data/lib/scorpion/dependency.rb +22 -58
- data/lib/scorpion/dependency/argument_dependency.rb +4 -4
- data/lib/scorpion/dependency/builder_dependency.rb +5 -5
- data/lib/scorpion/dependency/captured_dependency.rb +4 -6
- data/lib/scorpion/dependency/class_dependency.rb +3 -17
- data/lib/scorpion/dependency/module_dependency.rb +1 -1
- data/lib/scorpion/dependency_map.rb +16 -16
- data/lib/scorpion/error.rb +12 -9
- data/lib/scorpion/hunt.rb +33 -34
- data/lib/scorpion/hunter.rb +6 -6
- data/lib/scorpion/locale/en.yml +2 -2
- data/lib/scorpion/method.rb +11 -1
- data/lib/scorpion/object.rb +16 -31
- data/lib/scorpion/rack.rb +1 -1
- data/lib/scorpion/rack/middleware.rb +2 -1
- data/lib/scorpion/rails.rb +6 -6
- data/lib/scorpion/rails/active_record.rb +4 -4
- data/lib/scorpion/rails/active_record/association.rb +3 -3
- data/lib/scorpion/rails/active_record/relation.rb +3 -2
- data/lib/scorpion/rails/controller.rb +2 -2
- data/lib/scorpion/rails/job.rb +1 -1
- data/lib/scorpion/rails/mailer.rb +1 -1
- data/lib/scorpion/rails/nest.rb +11 -11
- data/lib/scorpion/rails/railtie.rb +2 -2
- data/lib/scorpion/rspec.rb +2 -2
- data/lib/scorpion/rspec/helper.rb +3 -3
- data/lib/scorpion/stinger.rb +19 -18
- data/lib/scorpion/version.rb +3 -3
- data/scorpion.gemspec +13 -13
- data/spec/internal/db/schema.rb +1 -1
- data/spec/lib/scorpion/attribute_set_spec.rb +4 -22
- data/spec/lib/scorpion/attribute_spec.rb +3 -8
- data/spec/lib/scorpion/chain_hunter_spec.rb +1 -1
- data/spec/lib/scorpion/dependency/argument_dependency_spec.rb +3 -7
- data/spec/lib/scorpion/dependency/builder_dependency_spec.rb +7 -7
- data/spec/lib/scorpion/dependency/module_dependency_spec.rb +3 -3
- data/spec/lib/scorpion/dependency_map_spec.rb +4 -25
- data/spec/lib/scorpion/dependency_spec.rb +18 -45
- data/spec/lib/scorpion/error_spec.rb +1 -1
- data/spec/lib/scorpion/hunt_spec.rb +16 -28
- data/spec/lib/scorpion/hunter_spec.rb +29 -21
- data/spec/lib/scorpion/object_spec.rb +20 -19
- data/spec/lib/scorpion/rack/middleware_spec.rb +4 -4
- data/spec/lib/scorpion/rack_spec.rb +1 -1
- data/spec/lib/scorpion/rails/active_record/association_spec.rb +3 -3
- data/spec/lib/scorpion/rails/active_record/model_spec.rb +3 -3
- data/spec/lib/scorpion/rails/active_record/relation_spec.rb +3 -3
- data/spec/lib/scorpion/rails/controller_spec.rb +8 -8
- data/spec/lib/scorpion/rails/job_spec.rb +1 -1
- data/spec/lib/scorpion/rspec/helper_spec.rb +11 -11
- data/spec/lib/scorpion_spec.rb +1 -1
- data/spec/spec_helper.rb +8 -10
- metadata +6 -6
- data/lib/scorpion/object_constructor.rb +0 -79
- data/spec/lib/scorpion/object_constructor_spec.rb +0 -124
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a82fd90f1ee52beb70fae54e337e99c4f707d250
|
4
|
+
data.tar.gz: 9f043a828f235431483c7f316deee1304c5e523d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef68c508a7cd4ae4f6eefa03c3453c73a699131931f2f9db833932cca966e64c1382e517cbf703052a6ff569e0a01370fdeec667a9d9e3ec641c046ab96a17b1
|
7
|
+
data.tar.gz: 12fba27a0a219c6a7db956b315d260635806cd7a265f53a11556371353fe0502d2d00ee3c16c31e73b68786771d6d9cc415f7ee8105f139c85929e671ab5e879
|
data/.rubocop.yml
CHANGED
@@ -1,62 +1,176 @@
|
|
1
|
-
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.4
|
3
|
+
|
4
|
+
Exclude:
|
5
|
+
- "**/node_modules/**/*"
|
6
|
+
- "api/bin/*"
|
7
|
+
- "api/db/schema.rb"
|
8
|
+
- "api/vendor/**/*"
|
9
|
+
- ".*"
|
10
|
+
- "/**/.*"
|
11
|
+
|
12
|
+
|
13
|
+
Bundler/OrderedGems:
|
14
|
+
Enabled: false
|
15
|
+
|
16
|
+
Style/EmptyMethod:
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
Style/ParallelAssignment:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
Lint/AmbiguousBlockAssociation:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
Lint/UselessAccessModifier:
|
26
|
+
Enabled: false
|
27
|
+
|
28
|
+
Lint/AmbiguousRegexpLiteral:
|
29
|
+
Enabled: false
|
30
|
+
|
31
|
+
Lint/AssignmentInCondition:
|
32
|
+
Enabled: false
|
33
|
+
|
34
|
+
Lint/UnusedMethodArgument:
|
35
|
+
Enabled: false
|
36
|
+
|
37
|
+
Lint/AmbiguousOperator:
|
38
|
+
Enabled: false
|
39
|
+
|
40
|
+
Metrics/ClassLength:
|
41
|
+
Max: 500
|
42
|
+
|
43
|
+
Metrics/LineLength:
|
2
44
|
Max: 120
|
3
45
|
|
4
|
-
|
5
|
-
|
46
|
+
Metrics/MethodLength:
|
47
|
+
Max: 25
|
48
|
+
|
49
|
+
Metrics/AbcSize:
|
50
|
+
Max: 24
|
6
51
|
|
7
|
-
|
52
|
+
Metrics/CyclomaticComplexity:
|
53
|
+
Max: 10
|
54
|
+
|
55
|
+
Metrics/ModuleLength:
|
56
|
+
Max: 500
|
57
|
+
|
58
|
+
Metrics/ParameterLists:
|
59
|
+
CountKeywordArgs: false
|
60
|
+
|
61
|
+
Metrics/BlockLength:
|
8
62
|
Enabled: false
|
9
63
|
|
10
|
-
Style/
|
64
|
+
Style/Alias:
|
11
65
|
Enabled: false
|
12
66
|
|
13
|
-
|
67
|
+
Layout/CommentIndentation:
|
14
68
|
Enabled: false
|
15
69
|
|
16
|
-
|
70
|
+
Layout/EmptyLines:
|
71
|
+
Enabled: false
|
72
|
+
|
73
|
+
Layout/EmptyLinesAroundBlockBody:
|
74
|
+
Enabled: false
|
75
|
+
|
76
|
+
Layout/EmptyLinesAroundClassBody:
|
77
|
+
Enabled: false
|
78
|
+
|
79
|
+
Layout/EmptyLinesAroundModuleBody:
|
80
|
+
Enabled: false
|
81
|
+
|
82
|
+
Style/FrozenStringLiteralComment:
|
83
|
+
Enabled: false
|
84
|
+
|
85
|
+
Style/DoubleNegation:
|
17
86
|
Enabled: false
|
18
87
|
|
19
|
-
Style/
|
88
|
+
Style/Documentation:
|
20
89
|
Enabled: false
|
21
90
|
|
22
|
-
Style/
|
91
|
+
Style/GuardClause:
|
23
92
|
Enabled: false
|
24
93
|
|
25
|
-
Style/
|
94
|
+
Style/HashSyntax:
|
26
95
|
Enabled: false
|
27
96
|
|
28
|
-
|
97
|
+
Layout/IndentArray:
|
29
98
|
Enabled: false
|
30
99
|
|
31
|
-
|
100
|
+
Layout/IndentationConsistency:
|
32
101
|
Enabled: false
|
33
102
|
|
34
|
-
|
103
|
+
Layout/IndentationWidth:
|
35
104
|
Enabled: false
|
36
105
|
|
37
|
-
Style/
|
106
|
+
Style/Lambda:
|
38
107
|
Enabled: false
|
39
108
|
|
40
|
-
Style/
|
109
|
+
Style/FrozenStringLiteralComment:
|
41
110
|
Enabled: false
|
42
111
|
|
43
|
-
Style/
|
44
|
-
|
112
|
+
Style/MultilineBlockChain:
|
113
|
+
Enabled: false
|
114
|
+
|
115
|
+
Style/NumericPredicate:
|
116
|
+
Enabled: false
|
117
|
+
|
118
|
+
Style/NumericLiterals:
|
119
|
+
Enabled: false
|
120
|
+
|
121
|
+
Style/OptionHash:
|
122
|
+
Enabled: true
|
123
|
+
|
124
|
+
Style/RegexpLiteral:
|
125
|
+
Enabled: false
|
126
|
+
|
127
|
+
Style/SignalException:
|
128
|
+
Enabled: false
|
129
|
+
|
130
|
+
Layout/SpaceAroundBlockParameters:
|
131
|
+
Enabled: false
|
45
132
|
|
46
133
|
Style/PercentLiteralDelimiters:
|
47
|
-
|
48
|
-
'%': '{}'
|
49
|
-
'%i': '{}'
|
50
|
-
'%q': '{}'
|
51
|
-
'%Q': '{}'
|
52
|
-
'%r': '{}'
|
53
|
-
'%s': '{}'
|
54
|
-
'%w': '{}'
|
55
|
-
'%W': '{}'
|
56
|
-
'%x': '{}'
|
134
|
+
Enabled: false
|
57
135
|
|
58
|
-
|
136
|
+
Layout/SpaceAroundOperators:
|
59
137
|
Enabled: false
|
60
138
|
|
61
|
-
|
62
|
-
Enabled: false
|
139
|
+
Layout/SpaceInsideBrackets:
|
140
|
+
Enabled: false
|
141
|
+
|
142
|
+
Layout/SpaceInsideParens:
|
143
|
+
Enabled: false
|
144
|
+
|
145
|
+
Layout/SpaceInsideStringInterpolation:
|
146
|
+
EnforcedStyle: space
|
147
|
+
|
148
|
+
Layout/SpaceInsidePercentLiteralDelimiters:
|
149
|
+
Enabled: false
|
150
|
+
|
151
|
+
Style/SpecialGlobalVars:
|
152
|
+
Enabled: false
|
153
|
+
|
154
|
+
Style/SymbolArray:
|
155
|
+
Enabled: false
|
156
|
+
|
157
|
+
Style/StringLiterals:
|
158
|
+
EnforcedStyle: double_quotes
|
159
|
+
|
160
|
+
Layout/TrailingBlankLines:
|
161
|
+
Enabled: false
|
162
|
+
|
163
|
+
Style/TrailingCommaInLiteral:
|
164
|
+
Enabled: false
|
165
|
+
|
166
|
+
Style/WhileUntilModifier:
|
167
|
+
Enabled: false
|
168
|
+
|
169
|
+
Style/UnneededInterpolation:
|
170
|
+
Enabled: false
|
171
|
+
|
172
|
+
Style/CaseEquality:
|
173
|
+
Enabled: false
|
174
|
+
|
175
|
+
Style/WordArray:
|
176
|
+
Enabled: false
|
data/Gemfile
CHANGED
@@ -1,21 +1,25 @@
|
|
1
|
-
source
|
1
|
+
source "https://rubygems.org"
|
2
2
|
|
3
3
|
# Specify your gem's dependencies in scorpion.gemspec
|
4
4
|
gemspec
|
5
5
|
|
6
6
|
group :test do
|
7
7
|
|
8
|
-
gem
|
9
|
-
|
10
|
-
gem
|
11
|
-
gem
|
12
|
-
gem
|
13
|
-
gem
|
14
|
-
gem
|
15
|
-
gem
|
16
|
-
gem
|
17
|
-
gem
|
18
|
-
gem
|
8
|
+
gem "rails", "~> 4.2"
|
9
|
+
|
10
|
+
gem "guard", "~> 2.12.8"
|
11
|
+
gem "spring"
|
12
|
+
gem "byebug"
|
13
|
+
gem "pry-byebug"
|
14
|
+
gem "guard-rspec"
|
15
|
+
gem "fuubar"
|
16
|
+
gem "yard"
|
17
|
+
gem "simplecov"
|
18
|
+
gem "ruby_gntp", "~> 0.3.4"
|
19
|
+
gem "awesome_print"
|
20
|
+
gem "nokogiri", "1.6.7.2"
|
21
|
+
|
22
|
+
gem "rubocop", "~> 0.50.0"
|
19
23
|
|
20
24
|
gem "codeclimate-test-reporter", require: nil
|
21
|
-
end
|
25
|
+
end
|
data/README.md
CHANGED
@@ -10,29 +10,30 @@ Add IoC to rails with minimal fuss and ceremony.
|
|
10
10
|
|
11
11
|
(Also check out [shog](http://github.com/phallguy/shog) for better rails logs)
|
12
12
|
|
13
|
-
<!--
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
13
|
+
<!-- vim-markdown-toc GFM -->
|
14
|
+
|
15
|
+
* [Dependency Injection](#dependency-injection)
|
16
|
+
* [Why might you _Want_ a DI FRamework?](#why-might-you-_want_-a-di-framework)
|
17
|
+
* [Setter/Default Injection](#setterdefault-injection)
|
18
|
+
* [Constructor/Ignorant Injection](#constructorignorant-injection)
|
19
|
+
* [Using a Framework...like Scorpion](#using-a-frameworklike-scorpion)
|
20
|
+
* [Using Scorpion](#using-scorpion)
|
21
|
+
* [Objects](#objects)
|
22
|
+
* [Configuration](#configuration)
|
23
|
+
* [Classes](#classes)
|
24
|
+
* [Modules](#modules)
|
25
|
+
* [Builders](#builders)
|
26
|
+
* [Hunting Delegates](#hunting-delegates)
|
27
|
+
* [Singletons](#singletons)
|
28
|
+
* [Nests](#nests)
|
29
|
+
* [Rails](#rails)
|
30
|
+
* [ActionController](#actioncontroller)
|
31
|
+
* [ActiveJob](#activejob)
|
32
|
+
* [ActiveRecord](#activerecord)
|
33
|
+
* [Contributing](#contributing)
|
34
|
+
* [License](#license)
|
35
|
+
|
36
|
+
<!-- vim-markdown-toc -->
|
36
37
|
|
37
38
|
## Dependency Injection
|
38
39
|
|
@@ -290,52 +291,6 @@ poker = scorpion.fetch Sharp
|
|
290
291
|
poker.poke # => "Sword"
|
291
292
|
```
|
292
293
|
|
293
|
-
#### Traits
|
294
|
-
|
295
|
-
Traits can be used to distinguish between dependencies of the same type. For
|
296
|
-
example a scorpion may be prepared to hunt for several weapons and the object
|
297
|
-
needs a blunt weapon.
|
298
|
-
|
299
|
-
```ruby
|
300
|
-
class Weapon; end
|
301
|
-
class Mace < Weapon; end
|
302
|
-
class Hammer < Weapon; end
|
303
|
-
class Sword < Weapon; end
|
304
|
-
|
305
|
-
scorpion.prepare do
|
306
|
-
hunt_for Hammer, :blunt
|
307
|
-
hunt_for Sword, :sharp
|
308
|
-
hunt_for Mace, :blunt, :sharp
|
309
|
-
end
|
310
|
-
|
311
|
-
scorpion.fetch Weapon, :blunt # => Hammer.new
|
312
|
-
scorpion.fetch Weapon, :sharp # => Sword.new
|
313
|
-
scorpion.fetch Weapon, :sharp, :blunt # => Mace.new
|
314
|
-
```
|
315
|
-
|
316
|
-
Modules can also be used to identify specific traits desired from the hunted
|
317
|
-
dependency.
|
318
|
-
|
319
|
-
```ruby
|
320
|
-
module Color; end
|
321
|
-
module Streaming; end
|
322
|
-
class Logger; end
|
323
|
-
class Console < Logger
|
324
|
-
include Color
|
325
|
-
end
|
326
|
-
class SysLog < Logger
|
327
|
-
include Streaming
|
328
|
-
end
|
329
|
-
|
330
|
-
scorpion.prepare do
|
331
|
-
hunt_for Console
|
332
|
-
hunt_for SysLog
|
333
|
-
end
|
334
|
-
|
335
|
-
scorpion.fetch Logger, Color # => Console.new
|
336
|
-
scorpion.fetch Logger, Streaming # => SysLog.new
|
337
|
-
```
|
338
|
-
|
339
294
|
#### Builders
|
340
295
|
|
341
296
|
Sometimes resolving the correct dependencies is a bit more dynamic. In those
|
data/Rakefile
CHANGED
data/app/README
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Here to make vim-rails work
|
data/bin/rspec
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
|
+
|
3
4
|
#
|
4
5
|
# This file was generated by Bundler.
|
5
6
|
#
|
@@ -9,7 +10,7 @@
|
|
9
10
|
|
10
11
|
require "pathname"
|
11
12
|
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
12
|
-
|
13
|
+
Pathname.new(__FILE__).realpath)
|
13
14
|
|
14
15
|
require "rubygems"
|
15
16
|
require "bundler/setup"
|
data/config.ru
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
# Dummy file to make vim-rails work
|
data/lib/scorpion-ioc.rb
CHANGED
data/lib/scorpion.rb
CHANGED
@@ -1,50 +1,41 @@
|
|
1
|
-
require
|
1
|
+
require "i18n"
|
2
2
|
|
3
|
-
I18n.load_path += Dir[ File.expand_path(
|
3
|
+
I18n.load_path += Dir[ File.expand_path( "../scorpion/locale/*.yml", __FILE__ ) ]
|
4
4
|
|
5
5
|
module Scorpion
|
6
6
|
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
15
|
-
require
|
16
|
-
require
|
17
|
-
require
|
18
|
-
require
|
19
|
-
require
|
20
|
-
|
21
|
-
|
22
|
-
#
|
7
|
+
require "scorpion/version"
|
8
|
+
require "scorpion/error"
|
9
|
+
require "scorpion/method"
|
10
|
+
require "scorpion/object"
|
11
|
+
require "scorpion/attribute_set"
|
12
|
+
require "scorpion/hunter"
|
13
|
+
require "scorpion/chain_hunter"
|
14
|
+
require "scorpion/dependency_map"
|
15
|
+
require "scorpion/hunt"
|
16
|
+
require "scorpion/dependency"
|
17
|
+
require "scorpion/nest"
|
18
|
+
require "scorpion/stinger"
|
19
|
+
require "scorpion/rails"
|
20
|
+
|
21
|
+
# Hunts for an object that satisfies the requested `contract`.
|
22
|
+
#
|
23
23
|
# @param [Class,Module,Symbol] contract describing the desired behavior of the dependency.
|
24
|
-
# @
|
25
|
-
# @param [Hash<Symbol,Object>] dependencies to inject into the object.
|
26
|
-
# @return [Object] an object that satisfies the contract and traits.
|
24
|
+
# @return [Object] an object that satisfies the contract.
|
27
25
|
# @raise [UnsuccessfulHunt] if a matching object cannot be found.
|
28
|
-
def
|
29
|
-
hunt = Hunt.new( self, contract,
|
26
|
+
def fetch( contract, *arguments, &block )
|
27
|
+
hunt = Hunt.new( self, contract, *arguments, &block )
|
30
28
|
execute hunt
|
31
29
|
end
|
32
30
|
|
33
|
-
# Hunts for an object that satisfies the requested `contract` regardless of
|
34
|
-
# traits.
|
35
|
-
# @see #fetch_by_traits
|
36
|
-
def fetch( contract, *arguments, **dependencies, &block )
|
37
|
-
fetch_by_traits( contract, nil, *arguments, **dependencies, &block )
|
38
|
-
end
|
39
|
-
|
40
31
|
# Creates a new object and feeds it it's dependencies.
|
41
32
|
# @param [Class] object_class a class that includes {Scorpion::Object}.
|
42
33
|
# @param [Array<Object>] args to pass to the constructor.
|
43
34
|
# @param [#call] block to pass to the constructor.
|
44
35
|
# @return [Scorpion::Object] the spawned object.
|
45
|
-
def spawn( hunt, object_class, *arguments,
|
36
|
+
def spawn( hunt, object_class, *arguments, &block )
|
46
37
|
if object_class < Scorpion::Object
|
47
|
-
object_class.spawn hunt, *arguments,
|
38
|
+
object_class.spawn hunt, *arguments, &block
|
48
39
|
else
|
49
40
|
object_class.new *arguments, &block
|
50
41
|
end
|
@@ -54,7 +45,7 @@ module Scorpion
|
|
54
45
|
# @param [Scorpion::Object] target to inject.
|
55
46
|
# @return [target]
|
56
47
|
def inject( target )
|
57
|
-
hunt = Scorpion::Hunt.new self, nil
|
48
|
+
hunt = Scorpion::Hunt.new self, nil
|
58
49
|
hunt.inject target
|
59
50
|
|
60
51
|
target
|
@@ -64,14 +55,14 @@ module Scorpion
|
|
64
55
|
# @param [Array<Object>] args to pass to the constructor.
|
65
56
|
# @param [#call] block to pass to the constructor.
|
66
57
|
# @return [Scorpion::Object] the spawned object.
|
67
|
-
def new( object_class, *arguments,
|
68
|
-
hunt = Hunt.new( self, object_class,
|
58
|
+
def new( object_class, *arguments, &block )
|
59
|
+
hunt = Hunt.new( self, object_class, *arguments, &block )
|
69
60
|
Scorpion::Dependency::ClassDependency.new( object_class ).fetch( hunt )
|
70
61
|
end
|
71
62
|
|
72
63
|
# Execute the `hunt` returning the desired dependency.
|
73
64
|
# @param [Hunt] hunt to execute.
|
74
|
-
# @return [Object] an object that satisfies the hunt contract
|
65
|
+
# @return [Object] an object that satisfies the hunt contract.
|
75
66
|
def execute( hunt )
|
76
67
|
fail "Not implemented"
|
77
68
|
end
|
@@ -102,6 +93,7 @@ module Scorpion
|
|
102
93
|
def logger
|
103
94
|
@logger || Scorpion.logger
|
104
95
|
end
|
96
|
+
|
105
97
|
def logger=( value )
|
106
98
|
@logger = value
|
107
99
|
end
|
@@ -125,7 +117,7 @@ module Scorpion
|
|
125
117
|
|
126
118
|
def self.instance=( scorpion )
|
127
119
|
if @instance_referenced
|
128
|
-
logger.warn "Replacing the global Scorpion.instance will not update any Scorpion::Nest instances created with the original scorpion."
|
120
|
+
logger.warn "Replacing the global Scorpion.instance will not update any Scorpion::Nest instances created with the original scorpion." # rubocop:disable Metrics/LineLength
|
129
121
|
@instance_referenced = false
|
130
122
|
end
|
131
123
|
@instance = scorpion
|
@@ -145,17 +137,12 @@ module Scorpion
|
|
145
137
|
instance.fetch dependencies, &block
|
146
138
|
end
|
147
139
|
|
148
|
-
# Hunt for dependency from the primary Scorpion {#instance}.
|
149
|
-
# @see #fetch_by_traits
|
150
|
-
def self.fetch_by_traits( dependencies, &block )
|
151
|
-
instance.fetch_by_traits dependencies, &block
|
152
|
-
end
|
153
|
-
|
154
140
|
# @!attribute logger
|
155
141
|
# @return [Logger] logger for the Scorpion framework to use.
|
156
142
|
def self.logger
|
157
143
|
@logger ||= defined?( ::Rails ) ? ::Rails.logger : Logger.new( STDOUT )
|
158
144
|
end
|
145
|
+
|
159
146
|
def self.logger=( value )
|
160
147
|
@logger = value
|
161
148
|
end
|
@@ -168,8 +155,8 @@ module Scorpion
|
|
168
155
|
|
169
156
|
# Used by concrete scorpions to notify the caller that the hunt was
|
170
157
|
# unsuccessful.
|
171
|
-
def unsuccessful_hunt( contract
|
172
|
-
fail UnsuccessfulHunt
|
158
|
+
def unsuccessful_hunt( contract )
|
159
|
+
fail UnsuccessfulHunt, contract
|
173
160
|
end
|
174
161
|
|
175
162
|
end
|