Sha256: 52652c36e1ef3e7acb9d6c5a6003b9ea41d96e0d13929925b1b7663e0576cb03
Contents?: true
Size: 914 Bytes
Versions: 1
Compression:
Stored size: 914 Bytes
Contents
# frozen_string_literal: true 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) model.class.send(:broadcast_updates, model.class, {}) end alias_method :broadcast_destroy, :broadcast_create def broadcast_update(model) changeset = model.respond_to?(:previous_changes) ? {changed: model.previous_changes.keys} : {} model.class.send(:broadcast_updates, model.class, changeset) model.class.send(:broadcast_updates, model.to_global_id, changeset) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cable_ready-5.0.0.pre10 | app/models/concerns/cable_ready/updatable/model_updatable_callbacks.rb |