Method: Module#anonymous?
- Defined in:
- lib/core/facets/module/anonymous.rb
#anonymous? ⇒ Boolean
A module may or may not have a name.
module M; end M.name # => “M”
m = Module.new m.name # => “”
A module gets a name when it is first assigned to a constant. Either via the module or class keyword or by an explicit assignment:
m = Module.new # creates an anonymous module M = m # => m gets a name here as a side-effect m.name # => “M”
18 19 20 21 22 |
# File 'lib/core/facets/module/anonymous.rb', line 18 def anonymous? # The name of an anonymous class is an empty # string in 1.8, and nil in 1.9. name.nil? || name.empty? end |