Sha256: 9bd0a9bcf09d4432bd833ade1400a95704d55cff4c0db6f783c22e1f01cb2ba1

Contents?: true

Size: 533 Bytes

Versions: 2

Compression:

Stored size: 533 Bytes

Contents

require 'hocus_pocus/middleware_util'

module HocusPocus
  class Middleware
    include MiddlewareUtil

    def initialize(app)
      @app = app
    end

    def call(env)
      @app.call(env).tap do |status, headers, body|
        if body.is_a?(ActionDispatch::Response) && (body.request.path !~ %r[^/*hocus_pocus/])
          body.body = insert_text body.body, :before, /<\/body>/i, %Q[<div id="#{HocusPocus::CONTAINER}" style="position:absolute; top:0; right: 0; font-size: small;"></div>]
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hocus_pocus-0.2.1 lib/hocus_pocus/middleware.rb
hocus_pocus-0.2.0 lib/hocus_pocus/middleware.rb