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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 83cc2664a50b6fa52391b9e4eb4298dc6fedddaf
4
- data.tar.gz: 5ad0dd976c29515fa2d0370dfe076c65dc0c8c72
2
+ SHA256:
3
+ metadata.gz: 2dec6c31f7811566996a4a3ca8c68bf1410b4de4aef812c5ac5253446f245251
4
+ data.tar.gz: c2b3051d4305fbbc5a52d127e7fbeb4da2542aa1e692507bb29040c825d94539
5
5
  SHA512:
6
- metadata.gz: d002e9f5811a17bcd97671e6d42a28bd887a026b6018c8d880599d13b819f751fe1ad787f53164fab26ccaa7d7e7c996a41801cf679452e13b272e952ed9829d
7
- data.tar.gz: cde9494df20a7f46619618c23c5fdb3f71a172dcdd9cb0a6d824e808284b703c2c55f0c1491ffd8bdecaca4578e4d04ba4b15b42ae858c80a3a28dbf36232b2c
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 || Scorpion.instance.build_nest
11
+ @nest = nest
12
12
  end
13
13
 
14
14
  def call( env )
15
- env[ENV_KEY] = prepare_scorpion( nest.conceive, env )
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
@@ -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|
@@ -1,5 +1,5 @@
1
1
  module Scorpion
2
- VERSION_NUMBER = "1.0.3".freeze
2
+ VERSION_NUMBER = "1.0.4".freeze
3
3
  VERSION_SUFFIX = "".freeze
4
4
  VERSION = "#{ VERSION_NUMBER }#{ VERSION_SUFFIX }".freeze
5
5
  end
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.3
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-05 00:00:00.000000000 Z
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.13
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