Class: ShotObserver

Inherits:
ActiveRecord::Observer
  • Object
show all
Defined in:
app/models/shot_observer.rb

Instance Method Summary collapse

Instance Method Details

#after_update(shot) ⇒ Object


4
5
6
# File 'app/models/shot_observer.rb', line 4

def after_update(shot)
  publish(:update, shot)
end

#publish(type, shot) ⇒ Object


8
9
10
11
12
13
14
15
16
# File 'app/models/shot_observer.rb', line 8

def publish(type, shot)
  Juggernaut.url = ENV['JUGG_URL']
  Juggernaut.publish("/observer/shot/#{shot.id}", {
    id: shot.id,
    type: type,
    klass: shot.class.name,
    record: shot.changes
  })
end