otr-activerecord 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/otr-activerecord/middleware/connection_management.rb +26 -0
- data/lib/otr-activerecord/version.rb +1 -1
- data/lib/otr-activerecord.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55c44318e27db688423b06e978b3d7ea6e6a220f
|
4
|
+
data.tar.gz: 97c0947f0d97ccb7800d1a3a53712f6bc11d204a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f6b09947d9b7c1afe08725b22eb84bf8bcb7116c269575b451098c06895f21ae521a6ff37a32bd0fcc751d9a0dba76ef1d8c18c40049cd3a4c221142a971543
|
7
|
+
data.tar.gz: 8bfa485e127c84d927c71d5bde6a7091e46852614b79348f71f940dd65eb36d8c277ada0ff87bbaec2758fd1a9c02ea83efef8b34a6687d0bd24ab81a02b6e07
|
data/README.md
CHANGED
@@ -24,9 +24,9 @@ This is because in ActiveRecord when that env variable is set it will merge its
|
|
24
24
|
|
25
25
|
#### 3. Enable ActiveRecord connection management in Rack apps
|
26
26
|
|
27
|
-
This
|
27
|
+
This middleware cleans up your database connections after each request. Add it to your `config.ru` file:
|
28
28
|
|
29
|
-
use ActiveRecord::
|
29
|
+
use OTR::ActiveRecord::ConnectionManagement
|
30
30
|
|
31
31
|
#### 4. Import ActiveRecord tasks into your Rakefile
|
32
32
|
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module OTR
|
2
|
+
module ActiveRecord
|
3
|
+
#
|
4
|
+
# Rack middleware that returns active db connections to the connection pool after a request completes.
|
5
|
+
#
|
6
|
+
class ConnectionManagement
|
7
|
+
def initialize(app)
|
8
|
+
@app = app
|
9
|
+
end
|
10
|
+
|
11
|
+
def call(env)
|
12
|
+
testing = env['rack.test'] == true
|
13
|
+
|
14
|
+
resp = @app.call env
|
15
|
+
resp[2] = ::Rack::BodyProxy.new resp[2] do
|
16
|
+
::ActiveRecord::Base.clear_active_connections! unless testing
|
17
|
+
end
|
18
|
+
resp
|
19
|
+
|
20
|
+
rescue Exception
|
21
|
+
::ActiveRecord::Base.clear_active_connections! unless testing
|
22
|
+
raise
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/otr-activerecord.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: otr-activerecord
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jordan Hollinger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -58,6 +58,7 @@ files:
|
|
58
58
|
- lib/otr-activerecord/compatibility_4.rb
|
59
59
|
- lib/otr-activerecord/compatibility_5.rb
|
60
60
|
- lib/otr-activerecord/defaults.rb
|
61
|
+
- lib/otr-activerecord/middleware/connection_management.rb
|
61
62
|
- lib/otr-activerecord/version.rb
|
62
63
|
- lib/tasks/otr-activerecord.rake
|
63
64
|
homepage: https://github.com/jhollinger/otr-activerecord
|