Class | Module |
In: |
lib/rake.rb
|
Parent: | Object |
Rake extensions to Module.
const_missing | -> | rake_original_const_missing |
Rename the original handler to make it available. |
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.rb, line 2451 2451: def const_missing(const_name) 2452: case const_name 2453: when :Task 2454: Rake.application.const_warning(const_name) 2455: Rake::Task 2456: when :FileTask 2457: Rake.application.const_warning(const_name) 2458: Rake::FileTask 2459: when :FileCreationTask 2460: Rake.application.const_warning(const_name) 2461: Rake::FileCreationTask 2462: when :RakeApp 2463: Rake.application.const_warning(const_name) 2464: Rake::Application 2465: else 2466: rake_original_const_missing(const_name) 2467: end 2468: end
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.rb, line 62 62: def rake_extension(method) 63: if instance_methods.include?(method.to_s) || instance_methods.include?(method.to_sym) 64: $stderr.puts "WARNING: Possible conflict with Rake extension: #{self}##{method} already exists" 65: else 66: yield 67: end 68: end