Class: SnowmanIO::Check

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Document, Mongoid::Timestamps
Defined in:
lib/snowman-io/models/check.rb

Constant Summary collapse

STATUS_NEVER_RUNNED =
"NEVER RUNNED"
STATUS_OK =
"OK"
STATUS_FAILED =
"FAILED"
TEMPLATE_LAST_VALUE_LIMIT =
"last_value_limit"
TEMPLATE_PREV_DAY_DATAPOINTS_LIMIT =
"prev_day_datapoints_limit"

Instance Method Summary collapse

Instance Method Details

#as_json(options = {}) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/snowman-io/models/check.rb', line 29

def as_json(options = {})
  super(options).tap do |o|
    o["id"] = o.delete("_id").to_s
    o["metric_id"] = o["metric_id"].to_s
    o["user_id"] = o["user_id"].to_s
  end
end

#cmp_fnObject



37
38
39
40
41
42
43
44
45
46
# File 'lib/snowman-io/models/check.rb', line 37

def cmp_fn
  case cmp
  when "more"
    -> (a, b) { a ? a > b : false }
  when "less"
    -> (a, b) { a ? a < b : false }
  else
    raise "unreachable"
  end
end