Module: StructuredWarnings::ClassMethods
- Included in:
- StructuredWarnings
- Defined in:
- lib/structured_warnings.rb
Overview
If you require 'test/unit'
after structured_warnings
you have to require 'structured_warnings/test'
manually, otherwise the test extensions will be added automatically.
Instance Method Summary collapse
-
#disabled_warnings ⇒ Object
returns an Array of all currently disabled warnings.
-
#disabled_warnings=(new_disabled_warnings) ⇒ Object
sets an array of all currently disabled warnings.
-
#warner ⇒ Object
Gives access to the currently used warner.
-
#warner=(new_warner) ⇒ Object
:stopdoc: Sets a new warner.
-
#with_disabled_warnings(disabled_warnings) ⇒ Object
Executes a block with the given set of disabled instances.
-
#with_warner(warner) ⇒ Object
Executes a block using the given warner.
Instance Method Details
#disabled_warnings ⇒ Object
returns an Array of all currently disabled warnings.
Note: Everyday users are supposed to use the methods in Warning::ClassMethods
36 37 38 |
# File 'lib/structured_warnings.rb', line 36 def disabled_warnings Dynamic[:disabled_warnings] end |
#disabled_warnings=(new_disabled_warnings) ⇒ Object
sets an array of all currently disabled warnings. It is expected that this array consists only of the Warning class and its subclasses.
Note: Everyday users are supposed to use the methods in Warning::ClassMethods
45 46 47 |
# File 'lib/structured_warnings.rb', line 45 def disabled_warnings=(new_disabled_warnings) Dynamic[:disabled_warnings] = new_disabled_warnings end |
#warner ⇒ Object
Gives access to the currently used warner. Default is an instance of StructuredWarnings::Warner
22 23 24 |
# File 'lib/structured_warnings.rb', line 22 def warner Dynamic[:warner] end |
#warner=(new_warner) ⇒ Object
:stopdoc: Sets a new warner
28 29 30 |
# File 'lib/structured_warnings.rb', line 28 def warner=(new_warner) Dynamic[:warner] = new_warner end |
#with_disabled_warnings(disabled_warnings) ⇒ Object
Executes a block with the given set of disabled instances.
Note: Everyday users are supposed to use the methods in Warning::ClassMethods
53 54 55 56 57 |
# File 'lib/structured_warnings.rb', line 53 def with_disabled_warnings(disabled_warnings) Dynamic.let(:disabled_warnings => disabled_warnings) do yield end end |
#with_warner(warner) ⇒ Object
Executes a block using the given warner. This may be used to suppress warnings to stdout, but fetch them and redirect them to somewhere else.
This behaviour is used in the StructuredWarnings::Assertions
14 15 16 17 18 |
# File 'lib/structured_warnings.rb', line 14 def with_warner(warner) Dynamic.let(:warner => warner) do yield end end |