Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
23 lines (19 sloc) 451 Bytes
class JuggernautObserver < ActiveRecord::Observer
observe :message, :channel
def after_create(rec)
publish(:create, rec)
end
def after_update(rec)
publish(:update, rec)
end
def after_destroy(rec)
publish(:destroy, rec)
end
protected
def publish(type, rec)
Juggernaut.publish("/observer", {
:type => type, :id => rec.id,
:klass => rec.class.name, :record => rec
})
end
end