Module: Skylight::Probes::Sinatra::ClassInstrumentation Private

Defined in:
lib/skylight/probes/sinatra.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#compile!(verb, path) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/skylight/probes/sinatra.rb', line 5

def compile!(verb, path, *)
  super.tap do |_, _, keys_or_wrapper, wrapper|
    wrapper ||= keys_or_wrapper

    # Deal with the situation where the path is a regex, and the default behavior
    # of Ruby stringification produces an unreadable mess
    if path.is_a?(Regexp)
      human_readable = "<sk-regex>%r{#{path.source}}</sk-regex>"
      wrapper.instance_variable_set(:@route_name, "#{verb} #{human_readable}")
    else
      wrapper.instance_variable_set(:@route_name, "#{verb} #{path}")
    end
  end
end