2022-11-02 09:41:30 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Chatable
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
def chat_channel
|
|
|
|
channel_class.new(chatable: self)
|
|
|
|
end
|
|
|
|
|
|
|
|
def create_chat_channel!(**args)
|
|
|
|
channel_class.create!(args.merge(chatable: self))
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def channel_class
|
2022-11-02 10:53:36 -04:00
|
|
|
"#{self.class}Channel".safe_constantize || raise("Unknown chatable #{self}")
|
2022-11-02 09:41:30 -04:00
|
|
|
end
|
|
|
|
end
|