Class: ShelterObserver

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

Instance Method Summary collapse

Instance Method Details

#after_update(shelter) ⇒ Object


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

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

#publish(type, shelter) ⇒ Object


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

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