lib/yard/code_objects/base.rb in yard-0.5.5 vs lib/yard/code_objects/base.rb in yard-0.5.6
- old
+ new
@@ -91,15 +91,15 @@
attr_reader :files
# The namespace the object is defined in. If the object is in the
# top level namespace, this is {Registry#root}
# @return [NamespaceObject] the namespace object
- attr_accessor :namespace
+ attr_reader :namespace
# The source code associated with the object
# @return [String, nil] source, if present, or nil
- attr_accessor :source
+ attr_reader :source
# Language of the source code associated with the object. Defaults to
# +:ruby+.
#
# @return [Symbol] the language type
@@ -112,11 +112,11 @@
# @return [String] a line of source
attr_accessor :signature
# The documentation string associated with the object
# @return [Docstring] the documentation string
- attr_accessor :docstring
+ attr_reader :docstring
# Marks whether or not the method is conditionally defined at runtime
# @return [Boolean] true if the method is conditionally defined at runtime
attr_accessor :dynamic
@@ -192,10 +192,11 @@
@current_file_has_comments = false
@name = name.to_sym
@source_type = :ruby
@tags = []
@docstring = Docstring.new('', self)
+ @namespace = nil
self.namespace = namespace
yield(self) if block_given?
end
# The name of the object
@@ -260,10 +261,10 @@
# @return [Object, nil] the custom attribute or nil if not found.
# @see #[]=
def [](key)
if respond_to?(key)
send(key)
- else
+ elsif instance_variable_defined?("@#{key}")
instance_variable_get("@#{key}")
end
end
# Sets a custom attribute on the object