| Module | StructuredWarnings::Base::ClassMethods |
| In: |
lib/structured_warnings/base.rb
|
This module extends StructuredWarnings::Base and each subclass. It may be used to activate or deactivate a set of warnings.
If called without a block, warnings of this type will be disabled in the current thread and all new child threads.
warn("this will be printed") # creates a StructuredWarnings::StandardWarning
# which is enabled by default
StructuredWarnings::Base.disable
warn("this will not be printed") # creates a StructuredWarnings::StandardWarning
# which is currently disabled
If called with a block, warnings of this type will be disabled in the dynamic scope of the given block.
StructuredWarnings::Base.disable do
warn("this will not be printed") # creates a StructuredWarnings::StandardWarning
# which is currently disabled
end
warn("this will be printed") # creates a StructuredWarnings::StandardWarning
# which is currently enabled
This method has the same semantics as disable, only with the opposite outcome. In general the last assignment wins, so that disabled warnings may be enabled again and so on.