Sha256: 092839ce4d0ec42d7a6696c89f2e0129fa35a184d57ed379cfad6978f2d5ba88

Contents?: true

Size: 635 Bytes

Versions: 2

Compression:

Stored size: 635 Bytes

Contents

module Tailog
  class Eval
    class << self
      attr_accessor :blacklist
    end

    self.blacklist = %w(/tailog)

    def initialize app
      @app = app
    end

    def call env
      if skip_call? env
        @app.call(env)
      else
        before = env["HTTP_TAILOG_EVAL_BEFORE"].presence
        after = env["HTTP_TAILOG_EVAL_AFTER"].presence

        eval before if before
        response = @app.call(env)
        eval after if after

        response
      end
    end

    private

    def skip_call? env
      Tailog::Eval.blacklist.any? do |path|
        env["PATH_INFO"].start_with? path
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tailog-0.4.1 lib/tailog/eval.rb
tailog-0.4.0 lib/tailog/eval.rb