Module: Kojak::Inspector

Defined in:
lib/kojak/inspector.rb

Overview

Public: Extend your class with this inspector module to get investigation functionality.

Example

class Dummy
  investigate :foo, :bar

  def foo
    *snip*...
  end

  def bar
    *snip*...
  end
end

Dummy.investigate! # ... or Kojak.investigate_all!

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(cls) ⇒ Object



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

def self.extended(cls)
  Kojak.mark_for_investigation(cls)
end

Instance Method Details

#investigate(*names) ⇒ Object

Public: Marks given methods for investigation.

names - The Array of method names to investigate.

Returns Array with names of all methods being under investigation.



48
49
50
51
52
# File 'lib/kojak/inspector.rb', line 48

def investigate(*names)
  Kojak.mark_for_investigation(self)
  @__kojak_investigate ||= []
  @__kojak_investigate.concat(names).uniq!
end

#investigate!Object

Public: Enables investigation of caller class.



55
56
57
58
59
60
# File 'lib/kojak/inspector.rb', line 55

def investigate!
  @__kojak_investigate.each do |name|
    m = instance_method(name)
    Kojak.register_investigator_for!(self, m)
  end
end