Class: BrokenWindow::MeasuredMetric

Inherits:
Object
  • Object
show all
Defined in:
app/models/broken_window/measured_metric.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(metric) ⇒ MeasuredMetric

Returns a new instance of MeasuredMetric.



11
12
13
# File 'app/models/broken_window/measured_metric.rb', line 11

def initialize(metric)
  @metric = metric
end

Instance Attribute Details

#metricObject (readonly)

Returns the value of attribute metric.



3
4
5
# File 'app/models/broken_window/measured_metric.rb', line 3

def metric
  @metric
end

Class Method Details

.find(param) ⇒ Object



6
7
8
# File 'app/models/broken_window/measured_metric.rb', line 6

def find(param)
  new(BrokenWindow::Metric.find(param))
end

.model_nameObject



33
34
35
# File 'app/models/broken_window/measured_metric.rb', line 33

def self.model_name
  Metric.model_name
end

Instance Method Details

#childrenObject



27
28
29
30
31
# File 'app/models/broken_window/measured_metric.rb', line 27

def children
  @metric.children.map do |metric|
    self.class.new(metric)
  end
end

#measurementObject



15
16
17
# File 'app/models/broken_window/measured_metric.rb', line 15

def measurement
  @measurement ||= @metric.latest_measurement unless container?
end

#old?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'app/models/broken_window/measured_metric.rb', line 23

def old?
  measurement && measurement.created_at < 3.days.ago
end

#statusObject



19
20
21
# File 'app/models/broken_window/measured_metric.rb', line 19

def status
  @status ||= calculate_status
end

#to_modelObject



37
38
39
# File 'app/models/broken_window/measured_metric.rb', line 37

def to_model
  metric
end