module Opbeat::Injections

@api private

Public Class Methods

const_defined?(const_name) click to toggle source
# File lib/opbeat/injections.rb, line 62
def self.const_defined? const_name
  const = Util.constantize(const_name) rescue nil
  !!const
end
hook_into(name) click to toggle source
# File lib/opbeat/injections.rb, line 45
def self.hook_into name
  return unless registration = lookup(name)

  if const_defined?(registration.const_name)
    installed[registration.const_name] = registration
    registration.install

    registration.require_paths.each do |path|
      require_hooks.delete path
    end
  end
end
installed() click to toggle source
# File lib/opbeat/injections.rb, line 24
def self.installed
  @installed ||= {}
end
lookup(require_path) click to toggle source
# File lib/opbeat/injections.rb, line 58
def self.lookup require_path
  require_hooks[require_path]
end
register(*args) click to toggle source
# File lib/opbeat/injections.rb, line 28
def self.register(*args)
  registration = Registration.new(*args)

  if const_defined?(registration.const_name)
    installed[registration.const_name] = registration
    registration.install
  else
    register_require_hook registration
  end
end
register_require_hook(registration) click to toggle source
# File lib/opbeat/injections.rb, line 39
def self.register_require_hook registration
  registration.require_paths.each do |path|
    require_hooks[path] = registration
  end
end
require_hooks() click to toggle source
# File lib/opbeat/injections.rb, line 20
def self.require_hooks
  @require_hooks ||= {}
end