class RuboCop::AST::Node

def parent_module_name

def parent_module_name
  # what class or module is this method/constant/etc definition in?
  # returns nil if answer cannot be determined
  ancestors = each_ancestor(:class, :module, :sclass, :casgn, :block)
  result    = ancestors.filter_map do |ancestor|
    parent_module_name_part(ancestor) do |full_name|
      return nil unless full_name
      full_name
    end
  end.reverse.join('::')
  result.empty? ? 'Object' : result
end