Sha256: 017a30dc75babc835038cae41f17370570e363357b2b3cb496f5cd46020f8135
Contents?: true
Size: 610 Bytes
Versions: 3
Compression:
Stored size: 610 Bytes
Contents
module Alerts 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
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
city-watch-0.5.7 | lib/city_watch/util/alerts.rb |
city-watch-0.5.6 | lib/city_watch/util/alerts.rb |
city-watch-0.5.5 | lib/city_watch/util/alerts.rb |