Class: GreekFire::Metric

Inherits:
Struct
  • Object
show all
Includes:
ActiveModel::Conversion
Defined in:
app/models/greek_fire/metric.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#labelsObject

Returns the value of attribute labels

Returns:

  • (Object)

    the current value of labels



4
5
6
# File 'app/models/greek_fire/metric.rb', line 4

def labels
  @labels
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



4
5
6
# File 'app/models/greek_fire/metric.rb', line 4

def name
  @name
end

#valueObject

Returns the value of attribute value

Returns:

  • (Object)

    the current value of value



4
5
6
# File 'app/models/greek_fire/metric.rb', line 4

def value
  @value
end

Class Method Details

.clear_metricsObject



22
23
24
25
# File 'app/models/greek_fire/metric.rb', line 22

def clear_metrics
  @registry.clear
  @dynamic_measures.clear
end

.metricsObject



16
17
18
19
20
# File 'app/models/greek_fire/metric.rb', line 16

def metrics
  (@dynamic_measures.map do |stat|
    stat.call
  end + @registry).flatten.compact
end

.register(measurer = nil, &block) ⇒ Object



10
11
12
13
14
# File 'app/models/greek_fire/metric.rb', line 10

def register(measurer=nil, &block)
  @registry << measurer unless measurer.nil?

  @dynamic_measures << block if block_given?
end