Class: RailsPendingMigrationErrors::Middleware
- Inherits:
-
Object
- Object
- RailsPendingMigrationErrors::Middleware
- Defined in:
- lib/rails_pending_migration_errors/middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
13 14 15 |
# File 'lib/rails_pending_migration_errors/middleware.rb', line 13 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rails_pending_migration_errors/middleware.rb', line 17 def call(env) status, headers, response = @app.call(env) response_body = nil return [status, headers, response] if status != 200 or !html_request?(headers, response) if RailsPendingMigrationErrors.needs_migrations? if RailsPendingMigrationErrors.page_load raise ActiveRecord::PendingMigrationError else response_body = append_response_body(headers, response) end end [status, headers, response_body ? [response_body] : response] end |