Class: Flapjack::Data::Condition
- Inherits:
-
Object
- Object
- Flapjack::Data::Condition
- Includes:
- Comparable, Zermelo::Records::RedisSet
- Defined in:
- lib/flapjack/data/condition.rb
Class Method Summary collapse
- .for_name(n) ⇒ Object
-
.healthy ⇒ Object
class methods rather than constants, as these may come from config data in the future; name => priority.
- .healthy?(c) ⇒ Boolean
- .most_unhealthy ⇒ Object
- .unhealthy ⇒ Object
Instance Method Summary collapse
Class Method Details
.for_name(n) ⇒ Object
62 63 64 65 66 |
# File 'lib/flapjack/data/condition.rb', line 62 def self.for_name(n) c = Flapjack::Data::Condition.new(:name => n, :priority => self.healthy[n.to_s] || self.unhealthy[n.to_s] ) c.valid? ? c : nil end |
.healthy ⇒ Object
class methods rather than constants, as these may come from config data in the future; name => priority
18 19 20 21 22 |
# File 'lib/flapjack/data/condition.rb', line 18 def self.healthy { 'ok' => 1 } end |
.healthy?(c) ⇒ Boolean
54 55 56 |
# File 'lib/flapjack/data/condition.rb', line 54 def self.healthy?(c) self.healthy.keys.include?(c) end |
.most_unhealthy ⇒ Object
58 59 60 |
# File 'lib/flapjack/data/condition.rb', line 58 def self.most_unhealthy self.unhealthy.min_by {|_, pri| pri }.first end |
.unhealthy ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/flapjack/data/condition.rb', line 24 def self.unhealthy { 'critical' => -3, 'warning' => -2, 'unknown' => -1 } end |
Instance Method Details
#<=>(cond) ⇒ Object
11 12 13 14 |
# File 'lib/flapjack/data/condition.rb', line 11 def <=>(cond) return nil unless cond.is_a?(Flapjack::Data::Condition) self.priority <=> cond.priority end |
#save_allowed? ⇒ Boolean
50 51 52 |
# File 'lib/flapjack/data/condition.rb', line 50 def save_allowed? false end |