Sha256: a3e03483efa28682510c031e760c821106ee0352f19d06d41955a82a67844cb5
Contents?: true
Size: 1.5 KB
Versions: 2
Compression:
Stored size: 1.5 KB
Contents
module God class Metric attr_accessor :watch, :destination, :conditions def initialize(watch, destination = nil) self.watch = watch self.destination = destination self.conditions = [] end # Instantiate a Condition of type +kind+ and pass it into the optional # block. Attributes of the condition must be set in the config file def condition(kind) # create the condition begin c = Condition.generate(kind, self.watch) 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 # test generic and specific validity unless Condition.valid?(c) && c.valid? abort "Exiting on invalid condition" end # 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 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 def enable self.conditions.each do |c| Hub.attach(c, self) end end def disable self.conditions.each do |c| Hub.detach(c) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
god-0.6.0 | lib/god/metric.rb |
god-0.5.0 | lib/god/metric.rb |