Class: Warp::Instrument
- Inherits:
-
Object
- Object
- Warp::Instrument
- Defined in:
- lib/warp/instrument.rb
Instance Attribute Summary collapse
-
#calls ⇒ Object
Returns the value of attribute calls.
-
#enabled ⇒ Object
Returns the value of attribute enabled.
-
#klass ⇒ Object
Returns the value of attribute klass.
-
#method ⇒ Object
Returns the value of attribute method.
Class Method Summary collapse
Instance Method Summary collapse
- #enabled? ⇒ Boolean
-
#initialize(klass, method) ⇒ Instrument
constructor
A new instance of Instrument.
- #log(args) ⇒ Object
- #reset ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(klass, method) ⇒ Instrument
Returns a new instance of Instrument.
21 22 23 24 25 26 27 28 29 |
# File 'lib/warp/instrument.rb', line 21 def initialize(klass, method) self.klass = klass self.method = method self.enabled = false self.calls = [] setup_hook self.class.send(:register, self) end |
Instance Attribute Details
#calls ⇒ Object
Returns the value of attribute calls.
19 20 21 |
# File 'lib/warp/instrument.rb', line 19 def calls @calls end |
#enabled ⇒ Object
Returns the value of attribute enabled.
19 20 21 |
# File 'lib/warp/instrument.rb', line 19 def enabled @enabled end |
#klass ⇒ Object
Returns the value of attribute klass.
19 20 21 |
# File 'lib/warp/instrument.rb', line 19 def klass @klass end |
#method ⇒ Object
Returns the value of attribute method.
19 20 21 |
# File 'lib/warp/instrument.rb', line 19 def method @method end |
Class Method Details
.for(klass, method) ⇒ Object
4 5 6 7 8 |
# File 'lib/warp/instrument.rb', line 4 def for(klass, method) @@registry ||= {} @@registry[klass] ||= {} @@registry[klass][method] || new(klass, method) end |
Instance Method Details
#enabled? ⇒ Boolean
41 42 43 |
# File 'lib/warp/instrument.rb', line 41 def enabled? enabled end |
#log(args) ⇒ Object
45 46 47 |
# File 'lib/warp/instrument.rb', line 45 def log(args) calls << args if enabled? end |
#reset ⇒ Object
31 32 33 |
# File 'lib/warp/instrument.rb', line 31 def reset self.calls = [] end |
#run ⇒ Object
35 36 37 38 39 |
# File 'lib/warp/instrument.rb', line 35 def run enable yield disable end |