{"record":{"id":"a96b53c87e152939","repo":"mongodb/mongoid","slug":"a-class-which-includes-mongoid-document-is-expect","errorCode":null,"errorMessage":"A class which includes Mongoid::Document is expected","messagePattern":"A class which includes Mongoid::Document is expected","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/mongoid/document.rb","lineNumber":303,"sourceCode":"      return unless attributes.key?(stored) || !relation.blank?\n\n      if relation.nil?\n        attributes.delete(stored)\n      else\n        attributes[stored] = relation.send(:as_attributes)\n      end\n    end\n\n    # Checks that the given argument is an instance of `Mongoid::Document`.\n    #\n    # @param klass [ Class ] The class to test.\n    #\n    # @raise [ ArgumentError ] if the class does not include\n    #   Mongoid::Document.\n    def mongoid_document_check!(klass)\n      return if klass.include?(Mongoid::Document)\n\n      raise ArgumentError, 'A class which includes Mongoid::Document is expected'\n    end\n\n    # Constructs a hash representing the internal state of this object,\n    # suitable for passing to #internal_state=.\n    #\n    # @return [ Hash ] the map of internal state values\n    def internal_state\n      {\n        id: _id,\n        changed_attributes: changed_attributes,\n        errors: errors,\n        new_record: new_record?,\n        destroyed: destroyed?,\n        discriminator_key_was: self.class.discriminator_value\n      }\n    end\n\n    # Updates the value of the discriminator_key for this object, setting its","sourceCodeStart":285,"sourceCodeEnd":321,"githubUrl":"https://github.com/mongodb/mongoid/blob/0da0e23d71adfbad31128c18e5e2c8c301c6f7c4/lib/mongoid/document.rb#L285-L321","documentation":"Error \"A class which includes Mongoid::Document is expected\" thrown in mongodb/mongoid.","triggerScenarios":"Thrown at lib/mongoid/document.rb:303 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0da0e23d71adfbad31128c18e5e2c8c301c6f7c4","analyzedAt":"2026-08-23T06:25:47.656Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}