Class: MigrationButton::Middleware
- Inherits:
-
ActiveRecord::Migration::CheckPending
- Object
- ActiveRecord::Migration::CheckPending
- MigrationButton::Middleware
- Defined in:
- lib/migration_button/middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
- #migrations_status_response ⇒ Object
- #protected_app_call(env) ⇒ Object
- #render_migrations_status ⇒ Object
Instance Method Details
#call(env) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/migration_button/middleware.rb', line 7 def call(env) case env['PATH_INFO'] when /#{MigrationButton.mount_path}/, %r(\A/{0,2}#{::Rails.application.config.assets.prefix}) @app.call env else protected_app_call(env) { super } end end |
#migrations_status_response ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/migration_button/middleware.rb', line 26 def migrations_status_response [ 500, {'Content-Type' => 'text/html; charset=utf-8'}, [render_migrations_status] ] end |
#protected_app_call(env) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/migration_button/middleware.rb', line 17 def protected_app_call(env) yield.tap do self.class.last_request = nil end rescue ActiveRecord::PendingMigrationError self.class.last_request = Rack::Request.new(env) migrations_status_response end |
#render_migrations_status ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/migration_button/middleware.rb', line 34 def render_migrations_status MigrationButton::RunnerController .render('index', assigns: { page: MigrationButton::RunnerController.page }) end |