Module: Kojak::Central
- Included in:
- Kojak
- Defined in:
- lib/kojak/central.rb
Overview
Internal: An extension with central utilities. This module extends top level Kojak module, don’t use it directly.
Constant Summary collapse
- @@mtx =
Global mutex.
Mutex.new
- @@log =
Slow log of investigated methods. Contains list of called names in order of calling.
Array.new
- @@printer =
Global printer.
Printer::RandomlyColorized.new($stderr)
- @@investigated =
Investigated classes.
{}
Instance Method Summary collapse
-
#investigate! ⇒ Object
Internal: Enables investigation of all registered classes.
-
#investigated ⇒ Object
Internal: List of classes marked for investigation.
-
#mark_for_investigation(cls) ⇒ Object
Internal: Marks given class as investigated.
-
#print(caller) ⇒ Object
Internal: Prints investigation results and writes to slow log.
-
#slowlog ⇒ Object
Internal: Returns slow log array.
Instance Method Details
#investigate! ⇒ Object
Internal: Enables investigation of all registered classes.
50 51 52 |
# File 'lib/kojak/central.rb', line 50 def investigate! @@mtx.synchronize { @@investigated.values.each(&:investigate!) } end |
#investigated ⇒ Object
Internal: List of classes marked for investigation.
26 27 28 |
# File 'lib/kojak/central.rb', line 26 def investigated @@mtx.synchronize { @@investigated.values } end |
#mark_for_investigation(cls) ⇒ Object
Internal: Marks given class as investigated.
cls - The Class to register.
Returns list of investigated classes.
35 36 37 |
# File 'lib/kojak/central.rb', line 35 def mark_for_investigation(cls) @@mtx.synchronize { @@investigated[cls.object_id] = cls } end |
#print(caller) ⇒ Object
Internal: Prints investigation results and writes to slow log.
caller - The Caller to print.
Returns nothing.
44 45 46 47 |
# File 'lib/kojak/central.rb', line 44 def print(caller) @@mtx.synchronize { @@log << caller[:name] } @@printer.puts(Output.new(caller)) end |
#slowlog ⇒ Object
Internal: Returns slow log array.
21 22 23 |
# File 'lib/kojak/central.rb', line 21 def slowlog @@mtx.synchronize { @@log } end |