Sha256: 860f181f5a153ec58367d140870cf7292912cca7810ebb7c18ae887189ece647
Contents?: true
Size: 725 Bytes
Versions: 1
Compression:
Stored size: 725 Bytes
Contents
module Alerts module ClassMethods def send_alert(message,dat=nil) CityWatch.redis.zadd "#{CityWatch.config[:prefix]}::#{host}::#{self.name}::alerts", rcv_time, Yajl::Encoder.encode({:message => message, :data => dat, :when => rcv_time}) end def alerts @alerts ||= [] if block_given? @alerts.each do |a| yield a end else @alerts end nil end def get_alerts(host=host,num=5) CityWatch.redis.zrevrange "#{CityWatch.config[:prefix]}::#{host}::#{self.name}::alerts", 0, num - 1 end def send_alerts! get_alerts.map do |alert| puts "Alert: #{alert.inspect}" if CityWatch.debug? end end end def self.included(base) base.extend(ClassMethods) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
city-watch-0.5.4 | lib/city_watch/util/alerts.rb |