Class: BrokenWindow::Metric
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- BrokenWindow::Metric
- Defined in:
- app/models/broken_window/metric.rb
Constant Summary collapse
- VALUE_TYPES =
%w(percentage integer)- THRESHOLD_TYPES =
%w(min max)- VALID_CLASS_NAME =
/\A[A-Z][a-zA-Z_0-9\:]*\z/
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.format_value(value, value_type) ⇒ Object
30 31 32 33 |
# File 'app/models/broken_window/metric.rb', line 30 def self.format_value(value, value_type) formatter = "BrokenWindow::Formatters::#{value_type.camelize}".constantize.new formatter.call(value) end |
Instance Method Details
#arguments_hash ⇒ Object
22 23 24 25 26 27 28 |
# File 'app/models/broken_window/metric.rb', line 22 def arguments_hash if arguments.present? YAML::load(arguments) else {} end end |
#container? ⇒ Boolean
35 36 37 |
# File 'app/models/broken_window/metric.rb', line 35 def container? calculator.blank? end |
#latest_measurement ⇒ Object
18 19 20 |
# File 'app/models/broken_window/metric.rb', line 18 def latest_measurement measurements.latest_first.first end |