Method: ArSync.sync_send

Defined in:
lib/ar_sync/core.rb

.sync_send(to:, action:, model:, path: nil, field: nil, to_user: nil) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/ar_sync/core.rb', line 39

def self.sync_send(to:, action:, model:, path: nil, field: nil, to_user: nil)
  key = sync_key to, to_user, signature: false
  e = { action: action }
  e[:field] = field if field
  if model
    e[:class] = model.class.base_class.name
    e[:id] = model.id
  end
  event = ["#{key}#{path}", e]
  buffer = Thread.current[:ar_sync_compact_notifications]
  if buffer
    buffer << event
  else
    @sync_send_block&.call [event]
  end
end