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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +5 -0
  3. data/README.md +11 -2
  4. data/lib/emb/railtie.rb +5 -1
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7f3eb540be54e104585249da101c6dd0a77c22c5f7ace642be44b11927d71643
4
- data.tar.gz: c963843c42d593640a11201abbb64b698e353c3d674df53d027bbce363ee2df1
3
+ metadata.gz: 0c6f451b27da29d343a893e88a8ae949620e33213941a785088d0e66f1cbe8ab
4
+ data.tar.gz: 7eb7bc8fa4069bedc853d1580c5504a1a1fbbdff432ff458f61152487199de78
5
5
  SHA512:
6
- metadata.gz: cd19e8b5017cfa0d377a8940a6ed44ecdc78bb5ac5e0905cff9e364ff02d49f68714b4542d2af0fb5f5b89254c8736294c7a62e0ba1506138fa04c5b5ac6f645
7
- data.tar.gz: 3a66bb58df4664a86ccaddf991d584de31b7b7ffce1aacf5c4d1f8f9151e252e4409719fc20af54d2f52aabae6f66df9092546e8c91d19eda52b4804a9017dd4
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 (the Railtie
537
- skips insertion when it is already present):
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: emb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0.pre3
4
+ version: 0.4.0.pre4
5
5
  platform: ruby
6
6
  authors:
7
7
  - elcuervo