lib/yard/code_objects/method_object.rb in yard-0.4.0 vs lib/yard/code_objects/method_object.rb in yard-0.5.0
- old
+ new
@@ -50,19 +50,28 @@
# Sets the visibility
# @param [Symbol] v the new visibility (:public, :private, or :protected)
def visibility=(v) @visibility = v.to_sym end
+ # @return whether or not the method is the #initialize constructor method
+ def constructor?
+ name == :initialize && scope == :instance && namespace.is_a?(ClassObject)
+ end
+
# Tests if the object is defined as an attribute in the namespace
# @return [Boolean] whether the object is an attribute
def is_attribute?
- namespace.attributes[scope].has_key? name.to_s.gsub(/=$/, '')
+ return false unless namespace.is_a?(NamespaceObject)
+ attr_obj = namespace.attributes[scope][name.to_s.gsub(/=$/, '')]
+ return false unless attr_obj
+ attr_obj[name.to_s =~ /=$/ ? :write : :read] ? true : false
end
# Tests if the object is defined as an alias of another method
# @return [Boolean] whether the object is an alias
def is_alias?
+ return false unless namespace.is_a?(NamespaceObject)
namespace.aliases.has_key? self
end
# Tests boolean {#explicit} value.
#
@@ -73,9 +82,10 @@
# Returns all alias names of the object
# @return [Array<Symbol>] the alias names
def aliases
list = []
+ return list unless namespace.is_a?(NamespaceObject)
namespace.aliases.each do |o, aname|
list << o if aname == name && o.scope == scope
end
list
end