def qualified_const_defined?(path)
      raise NameError, "#{path.inspect} is not a valid constant name!" unless
        /^(::)?([A-Z]\w*)(::[A-Z]\w*)*$/ =~ path

      names = path.to_s.split('::')
      names.shift if names.first.empty?

      # We can't use defined? because it will invoke const_missing for the parent
      # of the name we are checking.
      names.inject(Object) do |mod, name|
        return false unless uninherited_const_defined?(mod, name)
        mod.const_get name
      end
      return true
    end
def qualified_const_defined?(path)
      raise NameError, "#{path.inspect} is not a valid constant name!" unless
        /^(::)?([A-Z]\w*)(::[A-Z]\w*)*$/ =~ path

      names = path.to_s.split('::')
      names.shift if names.first.empty?

      # We can't use defined? because it will invoke const_missing for the parent
      # of the name we are checking.
      names.inject(Object) do |mod, name|
        return false unless uninherited_const_defined?(mod, name)
        mod.const_get name
      end
      return true
    end
Is the provided constant path defined?