class ScoutApm::Instant::Page
an abstraction for manipulating the HTML we capture in the middleware
Public Class Methods
new(html)
click to toggle source
# File lib/scout_apm/instant/middleware.rb, line 8 def initialize(html) @html = html if html.is_a?(Array) @html = html.inject("") { |memo, str| memo + str } end @to_add_to_head = [] @to_add_to_body = [] end
Public Instance Methods
add_to_body(content)
click to toggle source
# File lib/scout_apm/instant/middleware.rb, line 23 def add_to_body(content) @to_add_to_body << content end
add_to_head(content)
click to toggle source
# File lib/scout_apm/instant/middleware.rb, line 19 def add_to_head(content) @to_add_to_head << content end
res()
click to toggle source
# File lib/scout_apm/instant/middleware.rb, line 27 def res i = @html.index("</body>") @html = @html.insert(i, @to_add_to_body.join("")) if i i = @html.index("</head>") @html = @html.insert(i, @to_add_to_head.join("")) if i @html end