Sha256: 97bc8455d39fe1e277684c76a5528fc64b4289310a99202f4ef739ff01ebf475

Contents?: true

Size: 1.52 KB

Versions: 1

Compression:

Stored size: 1.52 KB

Contents

module ActiveJobChannel
  class Error < StandardError; end

  class NoIdentifierError < ::ActiveJobChannel::Error
    attr_reader :job_class

    def initialize(job_class)
      @job_class = job_class
      super(generate_message)
    end

    private

    def generate_message
      'ActiveJobChannel has been configured to broadcast privately for ' \
        "#{job_class}, but an `ajc_identifier` has not been set. The " \
        'identifier should be made available in your job via a method or an ' \
        'instance variable, either named `ajc_identifier`. For details about ' \
        'setting up an identifier in your ActionCable Connection, visit ' \
        'http://guides.rubyonrails.org/' \
        "action_cable_overview.html#connection-setup\n\nTo broadcast " \
        'globally without an identifier, pass in ' \
        '`{ global_broadcast: true }` to `active_job_channel` as part of an ' \
        'options hash.'
    end
  end

  class UnnecessaryIdentifierError < ::ActiveJobChannel::Error
    attr_reader :job_class

    def initialize(job_class)
      @job_class = job_class
      super(generate_message)
    end

    private

    def generate_message
      'ActiveJobChannel has been configured to broadcast globally for ' \
        "#{job_class}, but an `ajc_identifier` has been set. If the job " \
        'information should be broadcast globally, remove the ' \
        '`ajc_identifier`. Otherwise, pass in `{ global_broadcast: true } ` ' \
        'to `active_job_channel` as part of an options hash'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_job_channel-0.4.0 lib/active_job_channel/exceptions.rb