Class: ScoutApm::Instant::Page
- Inherits:
-
Object
- Object
- ScoutApm::Instant::Page
- Defined in:
- lib/scout_apm/instant/middleware.rb
Overview
an abstraction for manipulating the HTML we capture in the middleware
Instance Method Summary collapse
- #add_to_body(content) ⇒ Object
- #add_to_head(content) ⇒ Object
-
#initialize(html) ⇒ Page
constructor
A new instance of Page.
- #res ⇒ Object
Constructor Details
#initialize(html) ⇒ Page
Returns a new instance of Page.
6 7 8 9 10 |
# File 'lib/scout_apm/instant/middleware.rb', line 6 def initialize(html) @html = html @to_add_to_head = [] @to_add_to_body = [] end |
Instance Method Details
#add_to_body(content) ⇒ Object
16 17 18 |
# File 'lib/scout_apm/instant/middleware.rb', line 16 def add_to_body(content) @to_add_to_body << content end |
#add_to_head(content) ⇒ Object
12 13 14 |
# File 'lib/scout_apm/instant/middleware.rb', line 12 def add_to_head(content) @to_add_to_head << content end |
#res ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/scout_apm/instant/middleware.rb', line 20 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 |