Sha256: 96af95990cea9f0303f0904f6e6a4c7b74f05e486a81fe1d715c016cb3f33ff3

Contents?: true

Size: 604 Bytes

Versions: 1

Compression:

Stored size: 604 Bytes

Contents

module Tennpipes
  class AuthenticityToken < Rack::Protection::AuthenticityToken
    def initialize(app, options = {})
      @app = app
      @except = options[:except]
      @except = Array(@except) unless @except.is_a?(Proc)
      super
    end

    def call(env)
      if except?(env)
        @app.call(env)
      else
        super
      end
    end

    def except?(env)
      return false unless @except
      path_info = env['PATH_INFO']
      @except.is_a?(Proc) ? @except.call(env) : @except.any?{|path|
        path.is_a?(Regexp) ? path.match(path_info) : path == path_info }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tennpipes-base-3.6.6 lib/tennpipes-base/application/authenticity_token.rb