emb 0.4.0.pre3 → 0.4.0.pre4
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/Gemfile +5 -0
- data/README.md +11 -2
- data/lib/emb/railtie.rb +5 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0c6f451b27da29d343a893e88a8ae949620e33213941a785088d0e66f1cbe8ab
|
|
4
|
+
data.tar.gz: 7eb7bc8fa4069bedc853d1580c5504a1a1fbbdff432ff458f61152487199de78
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 94e720e10c56ccca0655c7dab9e28ac71d1731a4da5206664338be49de3dd2756f2acc56aa938a0b949f22dbe38927e2231abfee44cdf5339646079d8bf01fd0
|
|
7
|
+
data.tar.gz: 115a9d1814d895c856f39f6a557625cdb19abb59628dca39e314f35ace1c97c171c5a44c3c06c53500a6dee4332602f43bc4da04f6dabf0da053524ca43b6030
|
data/Gemfile
CHANGED
|
@@ -9,6 +9,11 @@ gem 'redis-client'
|
|
|
9
9
|
gem 'rake', require: false
|
|
10
10
|
gem 'rspec', require: false
|
|
11
11
|
|
|
12
|
+
# Development-only: the Railtie integration suite boots a real Rails app so the
|
|
13
|
+
# real middleware-stack objects and boot order are exercised. Rails is never a
|
|
14
|
+
# runtime dependency of the gem. Select a line with RAILS_VERSION.
|
|
15
|
+
gem 'rails', ENV.fetch('RAILS_VERSION', '~> 8.0'), require: false
|
|
16
|
+
|
|
12
17
|
gem 'rubocop', require: false
|
|
13
18
|
gem 'rubocop-rake', require: false
|
|
14
19
|
gem 'rubocop-rspec', require: false
|
data/README.md
CHANGED
|
@@ -533,13 +533,22 @@ If your Gemfile loads `emb` before Rails is required (non-standard boot order),
|
|
|
533
533
|
guarded railtie require in `emb.rb` is skipped — add `require "emb/railtie"` in
|
|
534
534
|
`config/application.rb` right after `require "rails/all"` (or in an initializer).
|
|
535
535
|
|
|
536
|
-
The middleware is also safe to mount manually in any Rack app
|
|
537
|
-
|
|
536
|
+
The middleware is also safe to mount manually in any Rack app. In a Rails app,
|
|
537
|
+
set the opt-out as well so the Railtie does not add a second copy:
|
|
538
538
|
|
|
539
539
|
```ruby
|
|
540
|
+
# config/application.rb
|
|
541
|
+
config.emb.middleware = false
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
```ruby
|
|
545
|
+
# wherever you build the stack
|
|
540
546
|
use Emb::Middleware
|
|
541
547
|
```
|
|
542
548
|
|
|
549
|
+
A duplicate mount is harmless — clearing the per-thread scope is idempotent — but
|
|
550
|
+
the opt-out keeps the stack clean and makes the intended wiring explicit.
|
|
551
|
+
|
|
543
552
|
The scope is cleared even when the app raises, and a fresh scope starts
|
|
544
553
|
automatically with the next request. Loaders created but never used within a
|
|
545
554
|
request are dropped — the create-then-consume contract applies per request.
|
data/lib/emb/railtie.rb
CHANGED
|
@@ -13,9 +13,13 @@ if defined?(Rails::Railtie)
|
|
|
13
13
|
config.emb.middleware = true
|
|
14
14
|
config.emb.job_middleware = true
|
|
15
15
|
|
|
16
|
+
# Insertion is unconditional (opt-out excepted): during initialization the
|
|
17
|
+
# stack is a Rails::Configuration::MiddlewareStackProxy, which records
|
|
18
|
+
# operations but cannot be inspected. Duplicate insertion is safe because
|
|
19
|
+
# Emb::BatchScope clearing is idempotent, so manual mounts use the opt-out
|
|
20
|
+
# instead of relying on detection.
|
|
16
21
|
initializer 'emb.middleware' do |app|
|
|
17
22
|
next if config.emb.middleware == false
|
|
18
|
-
next if app.middleware.include?(Emb::Middleware)
|
|
19
23
|
|
|
20
24
|
app.middleware.use Emb::Middleware
|
|
21
25
|
end
|