lib/action_cable_notifications/channel.rb
def stream_notifications_for(model, options = {})

      # Default publication options
      options = {
        publication: model.model_name.name,
        cache: false,
        model_options: {},
        scope: :all
      }.merge(options).merge(params.deep_symbolize_keys)

      # These options cannot be overridden
      options[:model] = model

      publication = options[:publication]

      # Checks if the publication already exists in the channel
      if not @ChannelPublications.include?(publication)
        # Sets channel options
        @ChannelPublications[publication] = options

        # Checks if model already includes notification callbacks
        if !model.respond_to? :ChannelPublications
          model.send('include', ActionCableNotifications::Model)
        end

        # Sets broadcast options if they are not already present in the model
        if not model.ChannelPublications.key? publication
          model.broadcast_notifications_from publication, options[:model_options]
        else # Reads options configuracion from model
          options[:model_options] = model.ChannelPublications[publication]
        end

        # Start streaming
        stream_from publication, coder: ActiveSupport::JSON do |packet|
          packet.merge!({publication: publication})
          transmit_packet(packet, options)
        end
        # XXX: Transmit initial data

      end
    end
def stream_notifications_for(model, options = {})

      # Default publication options
      options = {
        publication: model.model_name.name,
        cache: false,
        model_options: {},
        scope: :all
      }.merge(options).merge(params.deep_symbolize_keys)

      # These options cannot be overridden
      options[:model] = model

      publication = options[:publication]

      # Checks if the publication already exists in the channel
      if not @ChannelPublications.include?(publication)
        # Sets channel options
        @ChannelPublications[publication] = options

        # Checks if model already includes notification callbacks
        if !model.respond_to? :ChannelPublications
          model.send('include', ActionCableNotifications::Model)
        end

        # Sets broadcast options if they are not already present in the model
        if not model.ChannelPublications.key? publication
          model.broadcast_notifications_from publication, options[:model_options]
        else # Reads options configuracion from model
          options[:model_options] = model.ChannelPublications[publication]
        end

        # Start streaming
        stream_from publication, coder: ActiveSupport::JSON do |packet|
          packet.merge!({publication: publication})
          transmit_packet(packet, options)
        end
        # XXX: Transmit initial data

      end
    end
Streams notification for ActiveRecord model changes

 @param [ActiveRecord::Base] model Model to watch for changes
 @param [Hash] options Streaming options