Module: Instrument
- Defined in:
- lib/instrument.rb
Defined Under Namespace
Classes: Error
Class Method Summary collapse
Class Method Details
.add(*raw_targets, &handler) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/instrument.rb', line 22 def self.add(*raw_targets, &handler) raw_targets.each do |raw_target| obj, meth = case raw_target when /^(.+)#(.+)$/ [$1.constantize, $2] when /^(.+)(?:\.|::)(.+)$/ [(class << $1.constantize; self; end), $2] else raise Error, "Bad target format: #{raw_target}" end instrument(obj, meth, &handler) end end |
.handlers ⇒ Object
18 19 20 |
# File 'lib/instrument.rb', line 18 def self.handlers @handlers ||= [] end |