module InfluxReporter::Injections

@api private

Public Class Methods

const_defined?(const_name) click to toggle source
# File lib/influx_reporter/injections.rb, line 64
def self.const_defined?(const_name)
  const = begin
            Util.constantize(const_name)
          rescue
            nil
          end
  !!const
end
hook_into(name) click to toggle source
# File lib/influx_reporter/injections.rb, line 47
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/influx_reporter/injections.rb, line 26
def self.installed
  @installed ||= {}
end
lookup(require_path) click to toggle source
# File lib/influx_reporter/injections.rb, line 60
def self.lookup(require_path)
  require_hooks[require_path]
end
register(*args) click to toggle source
# File lib/influx_reporter/injections.rb, line 30
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/influx_reporter/injections.rb, line 41
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/influx_reporter/injections.rb, line 22
def self.require_hooks
  @require_hooks ||= {}
end