Class: DocumentChannel

Inherits:
ApplicationCable::Channel show all
Includes:
Y::ActionCable
Defined in:
lib/generators/lexxy_realtime/install/templates/document_channel.rb

Overview

Syncs clients with the record's collaborative document. After storing each update, the Action Text attribute is refreshed from the full document.

Instance Method Summary collapse

Instance Method Details

#receive(data) ⇒ Object



31
32
33
34
35
# File 'lib/generators/lexxy_realtime/install/templates/document_channel.rb', line 31

def receive(data)
  return unless record

  sync_receive(data, record.find_or_create_collaborative_document(field).key)
end

#subscribedObject



24
25
26
27
28
29
# File 'lib/generators/lexxy_realtime/install/templates/document_channel.rb', line 24

def subscribed
  reject and return unless record&.collaborative_rich_text?(field)
  reject and return unless authorized?

  sync_subscribed(record.find_or_create_collaborative_document(field).key)
end