# File lib/god/metric.rb, line 14 def condition(kind) # create the condition begin c = Condition.generate(kind) rescue NoSuchConditionError => e abort e.message end # send to block so config can set attributes yield(c) if block_given? # call prepare on the condition c.prepare # abort if the Condition is invalid, the Condition will have printed # out its own error messages by now unless c.valid? abort end # inherit interval from meddle if no poll condition specific interval was set if c.kind_of?(PollCondition) && !c.interval if self.watch.interval c.interval = self.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" end end # remember self.conditions << c end