module DigitalCable::Broadcaster

Constants

OPERATIONS

Public Instance Methods

broadcast(identifier, method:, options:) click to toggle source
# File lib/digital_cable/broadcaster.rb, line 31
def broadcast(identifier, method:, options:)
  verify_method!(method)

  ActionCable.server.broadcast identifier, {
    "digitalCable" => true,
    "operation" => { method: method.to_s.camelize(:lower), options: options }
  }
end
broadcast_to(identifier, model, method:, options:) click to toggle source
# File lib/digital_cable/broadcaster.rb, line 40
def broadcast_to(identifier, model, method:, options:)
  verify_method!(method)

  identifier.broadcast_to model, {
    "digitalCable" => true,
    "operation" => { method: method.to_s.camelize(:lower), options: options }
  }
end

Private Instance Methods

verify_method!(method) click to toggle source
# File lib/digital_cable/broadcaster.rb, line 51
def verify_method!(method)
  raise DigitalCableError, "Undefined method" unless OPERATIONS.include?(method.to_sym)
end