Class: AnimalWeightObserver

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

Instance Method Summary collapse

Instance Method Details

#after_update(animal_weight) ⇒ Object


5
6
7
# File 'app/models/animal_weight_observer.rb', line 5

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

#publish(type, animal_weight) ⇒ Object


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

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