From b8bb54af7ff6652327d99f6a7cf5c96a3f3f876d Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Thu, 11 Feb 2010 23:15:04 +0100 Subject: defines Module#anonymous? --- .../lib/active_support/core_ext/module/anonymous.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 activesupport/lib/active_support/core_ext/module/anonymous.rb (limited to 'activesupport/lib/active_support/core_ext/module') diff --git a/activesupport/lib/active_support/core_ext/module/anonymous.rb b/activesupport/lib/active_support/core_ext/module/anonymous.rb new file mode 100644 index 0000000000..60d7d9410b --- /dev/null +++ b/activesupport/lib/active_support/core_ext/module/anonymous.rb @@ -0,0 +1,20 @@ +class Module + # 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" + # + def anonymous? + name == '' + end +end -- cgit v1.2.3