Sha256: ce998701efd69e92cad32700a7702e61559baa04f3d6458c25b1c5a6bb7f5567
Contents?: true
Size: 742 Bytes
Versions: 4
Compression:
Stored size: 742 Bytes
Contents
module CableReady module Updatable class ModelUpdatableCallbacks def initialize(operation, enabled_operations = %i[create update destroy]) @operation = operation @enabled_operations = enabled_operations end def after_commit(model) return unless @enabled_operations.include?(@operation) send("broadcast_#{@operation}", model) end private def broadcast_create(model) ActionCable.server.broadcast(model.class, {}) end alias_method :broadcast_destroy, :broadcast_create def broadcast_update(model) ActionCable.server.broadcast(model.class, {}) ActionCable.server.broadcast(model.to_global_id, {}) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems