Class: Rack::Mason

Inherits:
Object
  • Object
show all
Includes:
MasonHelper
Defined in:
lib/rack-mason.rb

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

Methods included from MasonHelper

#call

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, options = {}) #:nodoc:
  @app = app
  @options = options.freeze
end