add_constant(constant)
public
Adds constant if not already there. If it is, updates the comment,
value and/or is_alias_for of the known constant if they were empty/nil.
Show source
def add_constant constant
return constant unless @document_self
known = @constants_hash[constant.name]
if known then
known.comment = constant.comment if known.comment.empty?
known.value = constant.value if
known.value.nil? or known.value.strip.empty?
known.is_alias_for ||= constant.is_alias_for
else
@constants_hash[constant.name] = constant
add_to @constants, constant
end
constant
end