class Metrics::Instruments::Gauge

Attributes

units[R]

Public Class Methods

new(options = {}, &block) click to toggle source
# File lib/ruby-metrics/instruments/gauge.rb, line 8
def initialize(options = {}, &block)
  raise ArgumentError, "a block is required" unless block_given?
  @block = block
  @units = options[:units]
end

Public Instance Methods

as_json(*_) click to toggle source
# File lib/ruby-metrics/instruments/gauge.rb, line 18
def as_json(*_)
  value = get
  value.respond_to?(:as_json) ? value.as_json : value
end
get() click to toggle source
# File lib/ruby-metrics/instruments/gauge.rb, line 14
def get
  instance_exec(&@block)
end
to_json(*_) click to toggle source
# File lib/ruby-metrics/instruments/gauge.rb, line 23
def to_json(*_)
  as_json.to_json
end