Sha256: ab18ed0d4a464c97eeb430c793ec4995ce3d02d0d2f4ffb90482b0ca2e7e3ff6
Contents?: true
Size: 1.5 KB
Versions: 1
Compression:
Stored size: 1.5 KB
Contents
module God class Metric < Base attr_accessor :watch, :destination, :conditions def initialize(watch, destination) 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) 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 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
god-0.2.0 | lib/god/metric.rb |