Module: NewRelic::Security::Instrumentation::Sinatra::Base::Chain

Defined in:
lib/newrelic_security/instrumentation-security/sinatra/chain.rb

Class Method Summary collapse

Class Method Details

.instrument!Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/newrelic_security/instrumentation-security/sinatra/chain.rb', line 6

def self.instrument!
  ::Sinatra::Base.class_eval do 
    include NewRelic::Security::Instrumentation::Sinatra::Base

    alias_method :call_without_security, :call

    def call(env)
      retval = nil
      event = call_on_enter(env) { retval = call_without_security(env) }
      call_on_exit(event, retval) { return retval }
    end

    alias_method :route_eval_without_security, :route_eval

    def route_eval(&block)
      route_eval_on_enter { route_eval_without_security(&block) }
    end

    alias_method :dispatch_without_security, :dispatch!

    def dispatch!
      dispatch_on_enter { dispatch_without_security }
    end
  end
end