Class: SweetStaging::Rails::Middleware
- Inherits:
-
Object
- Object
- SweetStaging::Rails::Middleware
- Defined in:
- lib/sweet_staging/rails/middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
- #call!(env) ⇒ Object
- #in_silence ⇒ Object
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
4 5 6 |
# File 'lib/sweet_staging/rails/middleware.rb', line 4 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
8 9 10 |
# File 'lib/sweet_staging/rails/middleware.rb', line 8 def call(env) dup.call!(env) end |
#call!(env) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/sweet_staging/rails/middleware.rb', line 12 def call!(env) if env['PATH_INFO'] =~ /sweet\/staging/ #in_silence { @status, @headers, @response = @app.call(env) } ::Rails.logger.silence do @status, @headers, @response = @app.call(env) end else @status, @headers, @response = @app.call(env) end [@status, @headers, @response] end |
#in_silence ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/sweet_staging/rails/middleware.rb', line 25 def in_silence old_level = ::Rails.logger.level.dup begin ::Rails.logger.level = Logger::ERROR yield ensure ::Rails.logger.level = old_level end end |