Sha256: 4d4c8c122fab1b1e6bdad54cf76fdef29412eb04b116a801aa396511f14fbbfa

Contents?: true

Size: 566 Bytes

Versions: 1

Compression:

Stored size: 566 Bytes

Contents

class StopIt

  class << self
    def stop &block
      if block_given?
        @stop = block
      else
        @stop
      end
    end
  end

  def initialize(app)
    @app = app
  end

  def call(env)
    if stop?(env)
      return [200, { 'Content-Type' => 'text/html', 'Content-Length' => '0' }, []]
    else
      @app.call(env)
    end
  end

  private

  def stop?(env)
    StopIt.stop && StopIt.stop.call(
      env["PATH_INFO"],
      env["REMOTE_ADDR"],
      env["QUERY_STRING"],
      env["REQUEST_METHOD"],
      env["HTTP_USER_AGENT"]
    )
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
stop_it-0.1.0 lib/stop_it.rb