Class: Nanoc::Core::Instrumentor Private
- Inherits:
-
Object
- Object
- Nanoc::Core::Instrumentor
- Defined in:
- lib/nanoc/core/instrumentor.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Class Method Summary collapse
- .call(key, *args) ⇒ Object private
- .disable ⇒ Object private
- .enable ⇒ Object private
Class Method Details
.call(key, *args) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/nanoc/core/instrumentor.rb', line 26 def self.call(key, *args) return yield unless @enabled begin stopwatch = DDMetrics::Stopwatch.new stopwatch.start yield ensure stopwatch.stop Nanoc::Core::NotificationCenter.post(key, stopwatch.duration, *args) end end |
.disable ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
22 23 24 |
# File 'lib/nanoc/core/instrumentor.rb', line 22 def self.disable @enabled = false end |
.enable ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/nanoc/core/instrumentor.rb', line 9 def self.enable if block_given? begin enable yield ensure disable end else @enabled = true end end |