diff options
author | Xavier Noria <fxn@hashref.com> | 2010-02-11 23:15:04 +0100 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2010-02-11 23:15:04 +0100 |
commit | b8bb54af7ff6652327d99f6a7cf5c96a3f3f876d (patch) | |
tree | ad12a39f6056b0fee2f2803dfb6b14c5e56eb42d /activesupport/lib/active_support/core_ext/module | |
parent | eea28b07cf25d5c79f8edeb8bef5e0483b489425 (diff) | |
download | rails-b8bb54af7ff6652327d99f6a7cf5c96a3f3f876d.tar.gz rails-b8bb54af7ff6652327d99f6a7cf5c96a3f3f876d.tar.bz2 rails-b8bb54af7ff6652327d99f6a7cf5c96a3f3f876d.zip |
defines Module#anonymous?
Diffstat (limited to 'activesupport/lib/active_support/core_ext/module')
-rw-r--r-- | activesupport/lib/active_support/core_ext/module/anonymous.rb | 20 |
1 files changed, 20 insertions, 0 deletions
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 |