lib/god/metric.rb in resurrected_god-0.14.0 vs lib/god/metric.rb in resurrected_god-1.0.0

- old
+ new

@@ -30,11 +30,11 @@ # # Returns nothing. def condition(kind) # Create the condition. begin - c = Condition.generate(kind, self.watch) + c = Condition.generate(kind, watch) rescue NoSuchConditionError => e abort e.message end # Send to block so config can set attributes. @@ -42,46 +42,44 @@ # Prepare the condition. c.prepare # Test generic and specific validity. - unless Condition.valid?(c) && c.valid? - abort "Exiting on invalid condition" - end + abort 'Exiting on invalid condition' unless Condition.valid?(c) && c.valid? # Inherit interval from watch if no poll condition specific interval was # set. - if c.kind_of?(PollCondition) && !c.interval - if self.watch.interval - c.interval = self.watch.interval + if c.is_a?(PollCondition) && !c.interval + if watch.interval + c.interval = watch.interval else - abort "No interval set for Condition '#{c.class.name}' in Watch " + - "'#{self.watch.name}', and no default Watch interval from " + - "which to inherit." + abort "No interval set for Condition '#{c.class.name}' in Watch " \ + "'#{watch.name}', and no default Watch interval from " \ + 'which to inherit.' end end # Add the condition to the list. - self.conditions << c + conditions << c end # Enable all of this Metric's conditions. Poll conditions will be # scheduled and event/trigger conditions will be registered. # # Returns nothing. def enable - self.conditions.each do |c| - self.watch.attach(c) + conditions.each do |c| + watch.attach(c) end end # Disable all of this Metric's conditions. Poll conditions will be # halted and event/trigger conditions will be deregistered. # # Returns nothing. def disable - self.conditions.each do |c| - self.watch.detach(c) + conditions.each do |c| + watch.detach(c) end end end end