Sha256: aca670f46b8728e04d9325c416824ea0f51fa4806ee4de84874a5a8b61547f47

Contents?: true

Size: 785 Bytes

Versions: 8

Compression:

Stored size: 785 Bytes

Contents

# frozen_string_literal: true

module Mongoid
  module Errors

    # This error is raised when attempting the change the value of an
    # immutable attribute. For example, the _id attribute is immutable,
    # and attempting to change it on a document that has already been
    # persisted will result in this error.
    class ImmutableAttribute < MongoidError

      # Create the new error.
      #
      # @example Create the new error.
      #   ImmutableAttribute.new(:_id, "1234")
      #
      # @param [ Symbol | String ] name The name of the attribute.
      # @param [ Object ] value The attempted set value.
      def initialize(name, value)
        super(
          compose_message("immutable_attribute", { name: name, value: value })
        )
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
mongoid-8.1.7 lib/mongoid/errors/immutable_attribute.rb
mongoid-8.1.6 lib/mongoid/errors/immutable_attribute.rb
mongoid-8.1.5 lib/mongoid/errors/immutable_attribute.rb
mongoid-8.1.4 lib/mongoid/errors/immutable_attribute.rb
mongoid-8.1.3 lib/mongoid/errors/immutable_attribute.rb
mongoid-8.1.2 lib/mongoid/errors/immutable_attribute.rb
mongoid-8.1.1 lib/mongoid/errors/immutable_attribute.rb
mongoid-8.1.0 lib/mongoid/errors/immutable_attribute.rb