lib/yard/code_objects/class_object.rb in yard-0.4.0 vs lib/yard/code_objects/class_object.rb in yard-0.5.0
- old
+ new
@@ -11,11 +11,18 @@
super
if is_exception?
self.superclass ||= :Exception unless P(namespace, name) == P(:Exception)
else
- self.superclass ||= :Object unless P(namespace, name) == P(:Object)
+ case P(namespace, name).path
+ when "BasicObject"
+ nil
+ when "Object"
+ self.superclass ||= :BasicObject
+ else
+ self.superclass ||= :Object
+ end
end
end
# Whether or not the class is a Ruby Exception
#
@@ -31,11 +38,11 @@
# @return [Array<NamespaceObject>] the list of code objects that make up
# the inheritance tree.
def inheritance_tree(include_mods = false)
list = (include_mods ? mixins(:instance) : [])
if superclass.is_a?(Proxy) || superclass.respond_to?(:inheritance_tree)
- list += [superclass] unless superclass == P(:Object)
+ list += [superclass] unless superclass == P(:Object) || superclass == P(:BasicObject)
end
[self] + list.map do |m|
next m unless m.respond_to?(:inheritance_tree)
m.inheritance_tree(include_mods)
end.flatten
@@ -100,21 +107,21 @@
end
# Sets the superclass of the object
#
# @param [Base, Proxy, String, Symbol, nil] object the superclass value
- # @return [nil]
+ # @return [void]
def superclass=(object)
case object
when Base, Proxy, NilClass
@superclass = object
when String, Symbol
@superclass = Proxy.new(namespace, object)
else
raise ArgumentError, "superclass must be CodeObject, Proxy, String or Symbol"
end
- if name == @superclass.name && namespace != YARD::Registry.root
+ if name == @superclass.name && namespace != YARD::Registry.root && object.is_a?(String)
@superclass = Proxy.new(namespace.namespace, object)
end
if @superclass == self
msg = "superclass #{@superclass.inspect} cannot be the same as the declared class #{self.inspect}"