class Module

Core extension library

Rake extensions to Module.

Public Instance Methods

const_missing(const_name) click to toggle source

Check for deprecated uses of top level (i.e. in Object) uses of Rake class names. If someone tries to reference the constant name, display a warning and return the proper object. Using the –classic-namespace command line option will define these constants in Object and avoid this handler.

   # File lib/rake/ext/module.rb
21 def const_missing(const_name)
22   case const_name
23   when :Task
24     Rake.application.const_warning(const_name)
25     Rake::Task
26   when :FileTask
27     Rake.application.const_warning(const_name)
28     Rake::FileTask
29   when :FileCreationTask
30     Rake.application.const_warning(const_name)
31     Rake::FileCreationTask
32   when :RakeApp
33     Rake.application.const_warning(const_name)
34     Rake::Application
35   else
36     rake_original_const_missing(const_name)
37   end
38 end
Also aliased as: rake_original_const_missing
rake_extension(method) { || ... } click to toggle source

Check for an existing method in the current class before extending. IF the method already exists, then a warning is printed and the extension is not added. Otherwise the block is yielded and any definitions in the block will take effect.

Usage:

class String
  rake_extension("xyz") do
    def xyz
      ...
    end
  end
end
   # File lib/rake/ext/core.rb
20 def rake_extension(method)
21   if method_defined?(method)
22     $stderr.puts "WARNING: Possible conflict with Rake extension: #{self}##{method} already exists"
23   else
24     yield
25   end
26 end
rake_original_const_missing(const_name)

Rename the original handler to make it available.

Alias for: const_missing