Class: UnicornMetrics::Counter
- Inherits:
-
Object
- Object
- UnicornMetrics::Counter
- Extended by:
- Forwardable
- Defined in:
- lib/unicorn_metrics/counter.rb
Overview
UnicornMetrics::Counter is an atomic counter that conveniently wraps the Raindrops::Struct
Direct Known Subclasses
Defined Under Namespace
Classes: Stats
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#as_json ⇒ Hash
JSON representation of the object.
-
#initialize(name) ⇒ Counter
constructor
A new instance of Counter.
-
#reset ⇒ Object
Reset the counter.
- #type ⇒ Object
Constructor Details
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/unicorn_metrics/counter.rb', line 6 def name @name end |
Instance Method Details
#as_json ⇒ Hash
Returns JSON representation of the object.
33 34 35 36 37 38 39 40 |
# File 'lib/unicorn_metrics/counter.rb', line 33 def as_json(*) { name => { "type" => type, "value" => value } } end |
#reset ⇒ Object
Reset the counter
24 25 26 |
# File 'lib/unicorn_metrics/counter.rb', line 24 def reset @stats.value = 0 end |
#type ⇒ Object
28 29 30 |
# File 'lib/unicorn_metrics/counter.rb', line 28 def type "counter" end |