Class: StatsD::Instrument::Backends::CaptureBackend
- Inherits:
-
StatsD::Instrument::Backend
- Object
- StatsD::Instrument::Backend
- StatsD::Instrument::Backends::CaptureBackend
- Defined in:
- lib/statsd/instrument/backends/capture_backend.rb
Overview
The capture backend is used to capture the metrics that are collected, so you can run assertions on them.
Instance Attribute Summary collapse
-
#collected_metrics ⇒ Array<StatsD::Instrument::Metric>
readonly
The list of metrics that were collected.
-
#parent ⇒ Object
Returns the value of attribute parent.
Instance Method Summary collapse
-
#collect_metric(metric) ⇒ void
Adds a metric to the ist of collected metrics.
-
#initialize ⇒ CaptureBackend
constructor
A new instance of CaptureBackend.
-
#reset ⇒ void
Resets the list of collected metrics to an empty list.
Constructor Details
#initialize ⇒ CaptureBackend
Returns a new instance of CaptureBackend.
14 15 16 |
# File 'lib/statsd/instrument/backends/capture_backend.rb', line 14 def initialize reset end |
Instance Attribute Details
#collected_metrics ⇒ Array<StatsD::Instrument::Metric> (readonly)
Returns The list of metrics that were collected.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/statsd/instrument/backends/capture_backend.rb', line 10 class CaptureBackend < StatsD::Instrument::Backend attr_reader :collected_metrics attr_accessor :parent def initialize reset end # Adds a metric to the ist of collected metrics. # @param metric [StatsD::Instrument::Metric] The metric to collect. # @return [void] def collect_metric(metric) parent&.collect_metric(metric) @collected_metrics << metric end # Resets the list of collected metrics to an empty list. # @return [void] def reset @collected_metrics = [] end end |
#parent ⇒ Object
Returns the value of attribute parent.
12 13 14 |
# File 'lib/statsd/instrument/backends/capture_backend.rb', line 12 def parent @parent end |
Instance Method Details
#collect_metric(metric) ⇒ void
This method returns an undefined value.
Adds a metric to the ist of collected metrics.
21 22 23 24 |
# File 'lib/statsd/instrument/backends/capture_backend.rb', line 21 def collect_metric(metric) parent&.collect_metric(metric) @collected_metrics << metric end |
#reset ⇒ void
This method returns an undefined value.
Resets the list of collected metrics to an empty list.
28 29 30 |
# File 'lib/statsd/instrument/backends/capture_backend.rb', line 28 def reset @collected_metrics = [] end |