Sha256: 45ebcfe2d421c83534eb6dc6fbb3d6847fc5b27e73fb03a431ba4b53defce812

Contents?: true

Size: 813 Bytes

Versions: 6

Compression:

Stored size: 813 Bytes

Contents

# frozen_string_literal: true
# encoding: utf-8

module Mongoid
  module Errors

    # This error is raised when attempting to destroy a model which has
    # an association with dependency option set to restrict.
    class DeleteRestriction < MongoidError

      # Create the new callbacks error.
      #
      # @param [ Document ] document The document that was attempted to be
      #   destroyed.
      # @param [ Symbol ] association_name The name of the dependent
      #   association that prevents the document from being deleted.
      #
      # @since 3.0.0
      def initialize(document, association_name)
        super(
          compose_message(
            "delete_restriction",
            { document: document.class, relation: association_name }
          )
        )
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mongoid-7.3.5 lib/mongoid/errors/delete_restriction.rb
mongoid-7.3.4 lib/mongoid/errors/delete_restriction.rb
mongoid-7.3.3 lib/mongoid/errors/delete_restriction.rb
mongoid-7.3.2 lib/mongoid/errors/delete_restriction.rb
mongoid-7.3.1 lib/mongoid/errors/delete_restriction.rb
mongoid-7.3.0 lib/mongoid/errors/delete_restriction.rb