<commit_before># encoding: utf-8
module Mongoid #:nodoc:
  module Document
    extend ActiveSupport::Concern
    included do
      include Mongoid::Components

      attr_accessor :association_name
      attr_reader :new_record

      unless self.instance_of?(Class) and self.name == ""
        (@@descendants ||= {})[self] = :seen
      end
    end

    module ClassMethods #:nodoc:

      # Perform default behavior but mark the hierarchy as being hereditary.
      #
      # This method must remain in the +Document+ module, even though its
      # behavior affects items in the Hierarchy module.
      def inherited(subclass)
        super(subclass)
        self.hereditary = true
      end

      # Instantiate a new object, only when loaded from the database or when
      # the attributes have already been typecast.
      #
      # Example:
      #
      # <tt>Person.instantiate(:title => "Sir", :age => 30)</tt>
      def instantiate(attrs = nil, allocating = false)
        attributes = attrs || {}
        if attributes["_id"] || allocating
          document = allocate
          document.instance_variable_set(:@attributes, attributes)
          document.setup_modifications
          return document
        else
          return new(attrs)
        end
      end

      # Returns the classes that have included Mongoid::Document
      def self.descendents
        (@@descendants ||= {}).keys
      end

      # Returns all types to query for when using this class as the base.
      # *subclasses* is from activesupport. Note that a bug in *subclasses*
      # causes the first call to only return direct children, hence
      # the double call and unique.
      def _types<commit_msg>Move Mongoid::Document.descendents to the right spot<commit_after># encoding: utf-8
module Mongoid #:nodoc:
  module Document
    extend ActiveSupport::Concern
    included do
      include Mongoid::Components

      attr_accessor :association_name
      attr_reader :new_record

      unless self.instance_of?(Class) and self.name == ""
        (@@descendants ||= {})[self] = :seen
      end
    end

    # Returns all classes that have included Mongoid::Document
    def self.descendents
      (@@descendants ||= {}).keys
    end

    module ClassMethods #:nodoc:

      # Perform default behavior but mark the hierarchy as being hereditary.
      #
      # This method must remain in the +Document+ module, even though its
      # behavior affects items in the Hierarchy module.
      def inherited(subclass)
        super(subclass)
        self.hereditary = true
      end

      # Instantiate a new object, only when loaded from the database or when
      # the attributes have already been typecast.
      #
      # Example:
      #
      # <tt>Person.instantiate(:title => "Sir", :age => 30)</tt>
      def instantiate(attrs = nil, allocating = false)
        attributes = attrs || {}
        if attributes["_id"] || allocating
          document = allocate
          document.instance_variable_set(:@attributes, attributes)
          document.setup_modifications
          return document
        else
          return new(attrs)
        end
      end

      # Returns all types to query for when using this class as the base.
      # *subclasses* is from activesupport. Note that a bug in *subclasses*
      # causes the first call to only return direct children, hence
      # the double call and unique.
      def _types
{'fraction_non_alphanumeric': 0.07840279801807053, 'fraction_numerical': 0.0017487612940833576, 'mean_word_length': 2.3879565646594276, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '5795909', 'n_tokens_mistral': 913, 'n_tokens_neox': 884, 'n_words': 326}