class Module

def anonymous?


m.name # => "M"
M = m # => m gets a name here as a side-effect
m = Module.new # creates an anonymous module

via the +module+ or +class+ keyword or by an explicit assignment:
A module gets a name when it is first assigned to a constant. Either

m.name # => ""
m = Module.new

M.name # => "M"
module M; end

A module may or may not have a name.
def anonymous?
  # Uses blank? because the name of an anonymous class is an empty
  # string in 1.8, and nil in 1.9.
  name.blank?
end