scorpion-ioc 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/scorpion/rack/middleware.rb +13 -3
- data/lib/scorpion/rails/controller.rb +2 -1
- data/lib/scorpion/rails/nest.rb +5 -0
- data/lib/scorpion/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2dec6c31f7811566996a4a3ca8c68bf1410b4de4aef812c5ac5253446f245251
|
4
|
+
data.tar.gz: c2b3051d4305fbbc5a52d127e7fbeb4da2542aa1e692507bb29040c825d94539
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fe35344e749df6e51188d16ae5376c9a15ba76c1ca8d814055161a251de3ea090c97c1a686f51516af2aceb1cc16d130125a1833f1d081732143967ab219991
|
7
|
+
data.tar.gz: 973decbb90a6a1f9ad065554af749cf8f257f352fb9a65a15b6e7a16eacb97208605cf86942356f00eccc87d93f5ec5853ef0f32c4a798c768e233f697523530
|
@@ -8,13 +8,23 @@ module Scorpion
|
|
8
8
|
|
9
9
|
def initialize( app, nest = nil )
|
10
10
|
@app = app
|
11
|
-
@nest = nest
|
11
|
+
@nest = nest
|
12
12
|
end
|
13
13
|
|
14
14
|
def call( env )
|
15
|
-
|
15
|
+
# If we don't have a nest yet, build one from the configured global
|
16
|
+
# scorpion.
|
17
|
+
@nest ||= Scorpion.instance.build_nest
|
18
|
+
|
19
|
+
conceived = false
|
20
|
+
env[ENV_KEY] ||=
|
21
|
+
begin
|
22
|
+
conceived = true
|
23
|
+
prepare_scorpion( nest.conceive, env )
|
24
|
+
end
|
25
|
+
|
16
26
|
@app.call(env).tap do
|
17
|
-
free_scorpion( env )
|
27
|
+
free_scorpion( env ) if conceived
|
18
28
|
end
|
19
29
|
end
|
20
30
|
|
@@ -8,7 +8,6 @@ module Scorpion
|
|
8
8
|
|
9
9
|
ENV_KEY = "scorpion.instance".freeze
|
10
10
|
|
11
|
-
|
12
11
|
# Fetch an object from the controller's {#scorpion}.
|
13
12
|
# @see Scorpion#fetch
|
14
13
|
def fetch( *args, &block )
|
@@ -71,6 +70,8 @@ module Scorpion
|
|
71
70
|
end
|
72
71
|
|
73
72
|
def free_scorpion
|
73
|
+
return unless conceived_scorpion?
|
74
|
+
|
74
75
|
scorpion.try( :destroy )
|
75
76
|
request.env.delete ENV_KEY
|
76
77
|
end
|
data/lib/scorpion/rails/nest.rb
CHANGED
@@ -101,9 +101,14 @@ module Scorpion
|
|
101
101
|
end
|
102
102
|
|
103
103
|
def conceive_scorpion
|
104
|
+
@conceived_scorpion = true
|
104
105
|
nest.conceive
|
105
106
|
end
|
106
107
|
|
108
|
+
def conceived_scorpion?
|
109
|
+
!!@conceived_scorpion
|
110
|
+
end
|
111
|
+
|
107
112
|
def append_instance_hunts( scorpion )
|
108
113
|
scorpion.prepare do |hunter|
|
109
114
|
self.class.instance_hunts.each do |method, args, block|
|
data/lib/scorpion/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scorpion-ioc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Alexander
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-12-
|
11
|
+
date: 2018-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -223,7 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
223
223
|
version: '0'
|
224
224
|
requirements: []
|
225
225
|
rubyforge_project:
|
226
|
-
rubygems_version: 2.6
|
226
|
+
rubygems_version: 2.7.6
|
227
227
|
signing_key:
|
228
228
|
specification_version: 4
|
229
229
|
summary: Add IoC to rails with minimal fuss and ceremony
|