class Tracebin::Patches

This singleton class handles patching for any given library we wish to instrument. To create a new patch for a library, just create a file in the lib/patches directory with any name. These files typically contain code that will monkeypatch a given library. When you wish to execute the code in that file, just call its corresponding patch_ method. For example, if we have a file lib/patches/foo.rb, then we would just call:

::Tracebin::Patches.patch_foo

Constants

PATCH_METHOD_REGEX

Public Class Methods

handle_event(handler_name, event_data) click to toggle source
# File lib/tracebin/patches.rb, line 20
def handle_event(handler_name, event_data)
  handler = instance_variable_get "@#{handler_name}_event_handler"
  handler.call event_data unless handler.nil?
end
method_missing(method_sym, *args, &block) click to toggle source
Calls superclass method
# File lib/tracebin/patches.rb, line 25
def method_missing(method_sym, *args, &block)
  if method_sym.to_s =~ PATCH_METHOD_REGEX
    patch_name = $1
    instance_variable_set "@#{patch_name}_event_handler", block
    require "tracebin/patches/#{patch_name}"
  else
    super
  end
end
respond_to?(method_sym, include_private = false) click to toggle source
Calls superclass method
# File lib/tracebin/patches.rb, line 35
def respond_to?(method_sym, include_private = false)
  if method_sym.to_s =~ PATCH_METHOD_REGEX
    true
  else
    super
  end
end