module ActionCable::Channel::Naming

def channel_name

FooChats::BarAppearancesChannel.channel_name # => 'foo_chats:bar_appearances'
Chats::AppearancesChannel.channel_name # => 'chats:appearances'
ChatChannel.channel_name # => 'chat'

colon separators in the channel name.
If the channel is in a namespace, then the namespaces are represented by single
Returns the name of the channel, underscored, without the Channel ending.
def channel_name
  @channel_name ||= name.sub(/Channel$/, "").gsub("::", ":").underscore
end