Class: DCA::Redis::Notifier
- Inherits:
-
Object
- Object
- DCA::Redis::Notifier
- Defined in:
- lib/dca/notifier/redis/notifier.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(config) ⇒ Notifier
constructor
A new instance of Notifier.
- #push(object, event, options = {}) ⇒ Object
Constructor Details
#initialize(config) ⇒ Notifier
Returns a new instance of Notifier.
4 5 6 |
# File 'lib/dca/notifier/redis/notifier.rb', line 4 def initialize config Ohm.connect :url => "redis://#{config[:host]}:#{config[:port]}" end |
Instance Method Details
#push(object, event, options = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/dca/notifier/redis/notifier.rb', line 8 def push(object, event, = {}) session = Session.find(:uid => object.session, :project => DCA.project_name, :area => object.class.queue).first unless session.present? session = Session.create :uid => object.session, :created => Time.now, :project => DCA.project_name, :area => object.class.queue end if event == :analyze session.inc_analyze [:state] elsif event == :fetch session.inc_fetch [:state], [:result] ? :success : :failure elsif event == :failure session.add_failure [:exception] end end |