Class: Rack::Mason
Overview
If you are creating Rack middleware that changes the HTML response, inherit from Rack::Mason to get a head start. Rack::Mason takes care of the boilerplate Rack glue so that you can focus on simply changing the HTML.
There are two ways you can change the HTML: as a Nokogiri document or as a string. Simply define one of the following methods:
def update_body(doc)
... insert code that changes the doc ...
doc
end
Rack::Mason also provides some convenience methods for interacting with Rack and Nokogiri.
Instance Method Summary collapse
-
#initialize(app, options = {}) ⇒ Mason
constructor
Rack::Mason provides an initialize method so that your middleware doesn’t have to.
Methods included from MasonHelper
Constructor Details
#initialize(app, options = {}) ⇒ Mason
Rack::Mason provides an initialize method so that your middleware doesn’t have to.
27 28 29 30 |
# File 'lib/rack-mason.rb', line 27 def initialize(app, = {}) #:nodoc: @app = app @options = .freeze end |