Class: Rack::Assets
Constant Summary
Constants included from AssetHelpers
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Assets
constructor
A new instance of Assets.
Methods included from AssetHelpers
Constructor Details
#initialize(app) ⇒ Assets
Returns a new instance of Assets.
5 6 7 |
# File 'lib/rack/assets.rb', line 5 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rack/assets.rb', line 9 def call(env) status, headers, response = @app.call(env) return [status, headers, response] unless check_html?(headers, response) && status == 200 if response.respond_to?(:body) response_body = response.body else response_body = response.first end # Inject the html, css and js code to the view response_body.gsub!('</head>', "#{head_code}</head>") headers['Content-Length'] = response_body.bytesize.to_s [status, headers, [response_body]] end |