Class: Dtrace::Provider::Klass
- Inherits:
-
Object
- Object
- Dtrace::Provider::Klass
- Defined in:
- lib/dtrace/provider/klass.rb
Overview
A dynamically-created DTrace provider class.
Instance Method Summary collapse
-
#initialize(dof, probes) ⇒ Klass
constructor
A new instance of Klass.
- #method_missing(probe, *args, &block) ⇒ Object
Constructor Details
#initialize(dof, probes) ⇒ Klass
Returns a new instance of Klass.
13 14 15 16 17 18 19 |
# File 'lib/dtrace/provider/klass.rb', line 13 def initialize(dof, probes) # must stash a reference to the DOF in the provider: # on OSX at least, freeing the generated DOF removes # the probes from the kernel. @dof = dof @probes = probes end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(probe, *args, &block) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/dtrace/provider/klass.rb', line 21 def method_missing(probe, *args, &block) if @probes[probe].nil? raise Dtrace::Exception.new("no such probe in #{self.to_s}: #{probe.to_s}") else if @probes[probe].is_enabled? block.call @probes[probe] end end end |