<commit_before>module Mongomatic
  module InstanceMethods
    def self.included(klass)
      klass.send(:attr_accessor, :removed, :is_new, :errors)
      klass.send(:attr_reader, :doc)
      klass.send(:include, Modifiers)
    end
    
    # Public Instance Methods
    def initialize(doc_hash=Mongomatic::MHash.new, is_new=true)
      self.doc = doc_hash
      self.removed = false
      self.is_new  = is_new
      self.errors  = Mongomatic::Errors.new
      do_callback(:after_initialize)
    end
    
    # Insert the document into the database. Will return false if the document has
    # already been inserted or is invalid. Returns the generated BSON::ObjectId
    # for the new document. Will silently fail if MongoDB is unable to insert the
    # document, use insert! or send in {:safe => true} if you want a Mongo::OperationError.
    # If you want to raise the following errors also, pass in {:raise => true}
    #   * Raises Mongomatic::Exceptions::DocumentNotNew if document is not new
    #   * Raises Mongomatic::Exceptions::DocumentNotValid if there are validation errors
    def insert(opts={})
      if opts[:raise] == true
        raise Mongomatic::Exceptions::DocumentWasRemoved if removed?
        raise Mongomatic::Exceptions::DocumentNotNew unless new?
        raise Mongomatic::Exceptions::DocumentNotValid unless valid?
      else<commit_msg>put ActiveModelCompliancy back in when including Mongomatic module<commit_after>module Mongomatic
  module InstanceMethods
    def self.included(klass)
      klass.send(:attr_accessor, :removed, :is_new, :errors)
      klass.send(:attr_reader, :doc)
      klass.send(:include, Modifiers)
      klass.send(:include, ActiveModelCompliancy)
    end
    
    # Public Instance Methods
    def initialize(doc_hash=Mongomatic::MHash.new, is_new=true)
      self.doc = doc_hash
      self.removed = false
      self.is_new  = is_new
      self.errors  = Mongomatic::Errors.new
      do_callback(:after_initialize)
    end
    
    # Insert the document into the database. Will return false if the document has
    # already been inserted or is invalid. Returns the generated BSON::ObjectId
    # for the new document. Will silently fail if MongoDB is unable to insert the
    # document, use insert! or send in {:safe => true} if you want a Mongo::OperationError.
    # If you want to raise the following errors also, pass in {:raise => true}
    #   * Raises Mongomatic::Exceptions::DocumentNotNew if document is not new
    #   * Raises Mongomatic::Exceptions::DocumentNotValid if there are validation errors
    def insert(opts={})
      if opts[:raise] == true
        raise Mongomatic::Exceptions::DocumentWasRemoved if removed?
        raise Mongomatic::Exceptions::DocumentNotNew unless new?
        raise Mongomatic::Exceptions::DocumentNotValid unless valid?
      else
{'fraction_non_alphanumeric': 0.08136667840789011, 'fraction_numerical': 0.0, 'mean_word_length': 3.4583987441130297, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3378898', 'n_tokens_mistral': 796, 'n_tokens_neox': 781, 'n_words': 260}