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

Instance Method Details

#disabled_warningsObject

returns an Array of all currently disabled warnings.

Note: Everyday users are supposed to use the methods in Warning::ClassMethods



39
40
41
# File 'lib/structured_warnings.rb', line 39

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



48
49
50
# File 'lib/structured_warnings.rb', line 48

def disabled_warnings=(new_disabled_warnings)
  Dynamic[:disabled_warnings] = new_disabled_warnings
end

#warnerObject

Gives access to the currently used warner. Default is an instance of StructuredWarnings::Warner



25
26
27
# File 'lib/structured_warnings.rb', line 25

def warner
  Dynamic[:warner]
end

#warner=(new_warner) ⇒ Object

:stopdoc: Sets a new warner



31
32
33
# File 'lib/structured_warnings.rb', line 31

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



56
57
58
59
60
# File 'lib/structured_warnings.rb', line 56

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



17
18
19
20
21
# File 'lib/structured_warnings.rb', line 17

def with_warner(warner)
  Dynamic.let(:warner => warner) do
    yield
  end
end