module Ohai::Mixin::ConstantHelper

Public Instance Methods

recursive_remove_constants(object) click to toggle source
# File lib/ohai/mixin/constant_helper.rb, line 34
def recursive_remove_constants(object)
  if object.respond_to?(:constants)
    object.constants.each do |const|
      next unless strict_const_defined?(object, const)

      recursive_remove_constants(object.const_get(const))
      object.send(:remove_const, const)
    end
  end
end
remove_constants() click to toggle source
# File lib/ohai/mixin/constant_helper.rb, line 25
def remove_constants
  new_object_constants = Object.constants - @object_pristine.constants - [ :SortedSet ]
  new_object_constants.each do |constant|
    Object.send(:remove_const, constant) unless Object.const_get(constant).is_a?(Module)
  end

  recursive_remove_constants(Ohai::NamedPlugin)
end
strict_const_defined?(object, const) click to toggle source
# File lib/ohai/mixin/constant_helper.rb, line 45
def strict_const_defined?(object, const)
  if object.method(:const_defined?).arity == 1
    object.const_defined?(const)
  else
    object.const_defined?(const, false)
  end
end