Class: Module
- Inherits:
-
Object
- Object
- Module
- Defined in:
- lib/rake.rb,
lib/rake.rb
Overview
Rake extensions to Module.
Instance Method Summary collapse
-
#const_missing(const_name) ⇒ Object
Check for deprecated uses of top level (i.e. in Object) uses of Rake class names.
-
#rake_extension(method) ⇒ Object
Check for an existing method in the current class before extending.
-
#rake_original_const_missing ⇒ Object
Rename the original handler to make it available.
Instance Method Details
#const_missing(const_name) ⇒ Object
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.
2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 |
# File 'lib/rake.rb', line 2450 def const_missing(const_name) case const_name when :Task Rake.application.const_warning(const_name) Rake::Task when :FileTask Rake.application.const_warning(const_name) Rake::FileTask when :FileCreationTask Rake.application.const_warning(const_name) Rake::FileCreationTask when :RakeApp Rake.application.const_warning(const_name) Rake::Application else rake_original_const_missing(const_name) end end |
#rake_extension(method) ⇒ Object
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
62 63 64 65 66 67 68 |
# File 'lib/rake.rb', line 62 def rake_extension(method) if instance_methods.include?(method.to_s) || instance_methods.include?(method.to_sym) $stderr.puts "WARNING: Possible conflict with Rake extension: #{self}##{method} already exists" else yield end end |
#rake_original_const_missing ⇒ Object
Rename the original handler to make it available.
2443 |
# File 'lib/rake.rb', line 2443 alias :rake_original_const_missing :const_missing |