Module: Autoloaded::Warning Private
- Defined in:
- lib/autoloaded/warning.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Prints warning messages to stderr.
Class Attribute Summary collapse
-
.io ⇒ IO
private
The warning stream.
Class Method Summary collapse
-
.changing_autoload(keywords) ⇒ Module
private
Prints a warning message to #io concerning an existing autoloaded constant for which the autoloaded source file is being changed.
-
.enable(enabling) { ... } ⇒ Object
private
Enables or disables warning messages depending on the specified enabling argument.
-
.enabled? ⇒ true, false
private
Indicates whether warning messages are enabled or disabled.
-
.existing_constant(keywords) ⇒ Module
private
Prints a warning message to #io concerning a defined constant for which autoloading is being established.
Class Attribute Details
.io ⇒ IO
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The warning stream. Defaults to $stderr.
18 19 20 |
# File 'lib/autoloaded/warning.rb', line 18 def io @io || $stderr end |
Class Method Details
.changing_autoload(keywords) ⇒ Module
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Prints a warning message to #io concerning an existing autoloaded constant for which the autoloaded source file is being changed.
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/autoloaded/warning.rb', line 38 def changing_autoload(keywords) constant_name = fetch(keywords, :constant_name) old_source_filename = fetch(keywords, :old_source_filename) new_source_filename = fetch(keywords, :new_source_filename) host_source_location = fetch(keywords, :host_source_location) = "Existing autoload of \e[4m#{constant_name}\e[0m from " + "#{old_source_filename.inspect} is being overridden to " + "autoload from #{new_source_filename.inspect} -- avoid this " + "warning by using an \e[4monly\e[0m or an \e[4mexcept\e[0m " + "specification in the block at #{host_source_location}" warn end |
.enable(enabling) { ... } ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Enables or disables warning messages depending on the specified enabling argument.
64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/autoloaded/warning.rb', line 64 def enable(enabling) previous_value = instance_variable_defined?(:@disabled) && @disabled @disabled = not!(enabling) if block_given? begin return yield ensure @disabled = previous_value end end self end |
.enabled? ⇒ true, false
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Indicates whether warning messages are enabled or disabled.
84 85 86 |
# File 'lib/autoloaded/warning.rb', line 84 def enabled? not! @disabled end |
.existing_constant(keywords) ⇒ Module
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Prints a warning message to #io concerning a defined constant for which autoloading is being established.
102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/autoloaded/warning.rb', line 102 def existing_constant(keywords) constant_name = fetch(keywords, :constant_name) source_filename = fetch(keywords, :source_filename) host_source_location = fetch(keywords, :host_source_location) = "Existing definition of \e[4m#{constant_name}\e[0m obviates " + "autoloading from #{source_filename.inspect} -- avoid this " + "warning by using an \e[4monly\e[0m or an \e[4mexcept\e[0m " + "specification in the block at #{host_source_location}" warn end |