Class: Moni::MoniWatch
- Inherits:
-
Object
- Object
- Moni::MoniWatch
- Defined in:
- lib/moni/moni_watch.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #check_and_serialize ⇒ Object
- #checkable? ⇒ Boolean
- #failed? ⇒ Boolean
-
#initialize(hash) ⇒ MoniWatch
constructor
A new instance of MoniWatch.
- #passed? ⇒ Boolean
Constructor Details
#initialize(hash) ⇒ MoniWatch
Returns a new instance of MoniWatch.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/moni/moni_watch.rb', line 14 def initialize(hash) @name = hash.delete("name") @description = hash.delete("description") @proc = hash.delete("proc") if hash.has_key?("passed") @check_run = true @passed = hash.delete("passed") else @check_run = false end end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
13 14 15 |
# File 'lib/moni/moni_watch.rb', line 13 def description @description end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
13 14 15 |
# File 'lib/moni/moni_watch.rb', line 13 def name @name end |
Class Method Details
.from_serialized(serialized) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/moni/moni_watch.rb', line 4 def self.from_serialized(serialized) p "serialized" pp serialized hash = JSON.parse(serialized) p "hash" pp hash new(hash) end |
Instance Method Details
#check_and_serialize ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/moni/moni_watch.rb', line 26 def check_and_serialize { :name => @name, :description => @description, :passed => passed? } end |
#checkable? ⇒ Boolean
45 46 47 |
# File 'lib/moni/moni_watch.rb', line 45 def checkable? !!@proc end |
#failed? ⇒ Boolean
41 42 43 |
# File 'lib/moni/moni_watch.rb', line 41 def failed? !passed? end |
#passed? ⇒ Boolean
34 35 36 37 38 39 |
# File 'lib/moni/moni_watch.rb', line 34 def passed? if !@check_run @passed = @proc.call end @passed end |