lib/tabs/tabs.rb in tabs-1.0.0 vs lib/tabs/tabs.rb in tabs-1.0.1

- old
+ new

@@ -57,10 +57,16 @@ type = hget("metrics", key) metric_klass(type).new(key) end def counter_total(key) - raise UnknownMetricError.new("Unknown metric: #{key}") unless metric_exists?(key) + unless metric_exists?(key) + if block_given? + return yield + else + raise UnknownMetricError.new("Unknown metric: #{key}") + end + end raise MetricTypeMismatchError.new("Only counter metrics can be incremented") unless metric_type(key) == "counter" get_metric(key).total end def get_stats(key, period, resolution)