Class: Cosme::Middleware
- Inherits:
-
Object
- Object
- Cosme::Middleware
- Includes:
- ActionView::Helpers::TagHelper, Helpers
- Defined in:
- lib/cosme/middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
Methods included from Helpers
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
6 7 8 |
# File 'lib/cosme/middleware.rb', line 6 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/cosme/middleware.rb', line 10 def call(env) @env = env response = @app.call(env) return response unless Cosme.auto_cosmeticize? html = response_to_html(response) return response unless html new_html = insert_cosmeticize_tag(html) new_html = insert_cosme_js(new_html) new_response(response, new_html) end |