<commit_before># encoding: utf-8
module Mongoid # :nodoc:
  module Relations #:nodoc:
    module Macros #:nodoc:
      extend ActiveSupport::Concern

      included do
        class_inheritable_accessor :relations
        self.relations = {}

        # Convenience methods for the instance to know about attributes that
        # are located at the class level.
        delegate :relations, :to => "self.class"
      end

      module ClassMethods #:nodoc:

        # Adds the relation back to the parent document. This macro is
        # necessary to set the references from the child back to the parent
        # document. If a child does not define this relation calling
        # persistence methods on the child object will cause a save to fail.
        #
        # Options:
        #
        # name: A +Symbol+ that matches the name of the parent class.
        # options: The relation options as a +Hash+.
        # block: Optional block for defining relation extensions.
        #
        # Example:
        #
        #   class Person
        #     include Mongoid::Document
        #     embeds_many :addresses
        #   end
        #
        #   class Address
        #     include Mongoid::Document
        #     embedded_in :person, :inverse_of => :addresses
        #   end
        def embedded_in(name, options = {}, &block)
          self.embedded = true
          relate(
            name,
            metadatafy(name, Embedded::In, options, &block)
          )
        end

        # Adds the relation from a parent document to its children. The name
        # of the relation needs to be a pluralized form of the child class
        # name.
        #
        # Options:
        #
        # name: A +Symbol+ that is the plural child class name.
        # options: The relation options as a +Hash+.
        # block: Optional block for defining relation extensions.
        #
        # Example:
        #
        #   class Person
        #     include Mongoid::Document
        #     embeds_many :addresses
        #   end
        #
        #   class Address
        #     include Mongoid::Document
        #     embedded_in :person, :inverse_of => :addresses
        #   end
        def embeds_many(name, options = {}, &block)
          relate(
            name,
            metadatafy(name, Embedded::Many, options, &block)
          )
        end
        alias :embed_many :embeds_many

        # Adds the relation from a parent document to its child. The name
        # of the relation needs to be a singular form of the child class
        # name.
        #
        # Options:
        #
        # name: A +Symbol+ that is the plural child class name.
        # options: The relation options as a +Hash+.
        # block: Optional block for defining relation extensions.
        #
        # Example:
        #
        #   class Person
        #     include Mongoid::Document
        #     embeds_one :name
        #   end
        #
        #   class Name
        #     include Mongoid::Document
        #     embedded_in :person
        #   end
        def embeds_one(name, options = {}, &block)
          relate(
            name,
            metadatafy(name, Embedded::One, options, &block)
          )
          builder(name).creator(name)
        end
        alias :embed_one :embeds_one

        # Adds a relational association from the child Document to a Document in
        # another database or collection.
        #
        # Options:
        #
        # name: A +Symbol+ that is the related class name.
        # options: The relation options as a +Hash+.
        # block: Optional block for defining relation extensions.
        #
        # Example:
        #
        #   class Game
        #     include Mongoid::Document
        #     referenced_in :person
        #   end
        #
        #   class Person
        #     include Mongoid::Document
        #     references_one :game
        #   end
        def referenced_in(name, options = {}, &block)
          metadata = metadatafy(name, Referenced::In, options, &block)
          relate(name, metadata)
          reference(metadata)
        end

        # Adds a relational association from the child Document to a Document in
        # another database or collection. This differs from a normal<commit_msg>Removing aliases to embedded macros, relation ones already sacked<commit_after># encoding: utf-8
module Mongoid # :nodoc:
  module Relations #:nodoc:
    module Macros #:nodoc:
      extend ActiveSupport::Concern

      included do
        class_inheritable_accessor :relations
        self.relations = {}

        # Convenience methods for the instance to know about attributes that
        # are located at the class level.
        delegate :relations, :to => "self.class"
      end

      module ClassMethods #:nodoc:

        # Adds the relation back to the parent document. This macro is
        # necessary to set the references from the child back to the parent
        # document. If a child does not define this relation calling
        # persistence methods on the child object will cause a save to fail.
        #
        # Options:
        #
        # name: A +Symbol+ that matches the name of the parent class.
        # options: The relation options as a +Hash+.
        # block: Optional block for defining relation extensions.
        #
        # Example:
        #
        #   class Person
        #     include Mongoid::Document
        #     embeds_many :addresses
        #   end
        #
        #   class Address
        #     include Mongoid::Document
        #     embedded_in :person, :inverse_of => :addresses
        #   end
        def embedded_in(name, options = {}, &block)
          self.embedded = true
          relate(
            name,
            metadatafy(name, Embedded::In, options, &block)
          )
        end

        # Adds the relation from a parent document to its children. The name
        # of the relation needs to be a pluralized form of the child class
        # name.
        #
        # Options:
        #
        # name: A +Symbol+ that is the plural child class name.
        # options: The relation options as a +Hash+.
        # block: Optional block for defining relation extensions.
        #
        # Example:
        #
        #   class Person
        #     include Mongoid::Document
        #     embeds_many :addresses
        #   end
        #
        #   class Address
        #     include Mongoid::Document
        #     embedded_in :person, :inverse_of => :addresses
        #   end
        def embeds_many(name, options = {}, &block)
          relate(
            name,
            metadatafy(name, Embedded::Many, options, &block)
          )
        end

        # Adds the relation from a parent document to its child. The name
        # of the relation needs to be a singular form of the child class
        # name.
        #
        # Options:
        #
        # name: A +Symbol+ that is the plural child class name.
        # options: The relation options as a +Hash+.
        # block: Optional block for defining relation extensions.
        #
        # Example:
        #
        #   class Person
        #     include Mongoid::Document
        #     embeds_one :name
        #   end
        #
        #   class Name
        #     include Mongoid::Document
        #     embedded_in :person
        #   end
        def embeds_one(name, options = {}, &block)
          relate(
            name,
            metadatafy(name, Embedded::One, options, &block)
          )
          builder(name).creator(name)
        end

        # Adds a relational association from the child Document to a Document in
        # another database or collection.
        #
        # Options:
        #
        # name: A +Symbol+ that is the related class name.
        # options: The relation options as a +Hash+.
        # block: Optional block for defining relation extensions.
        #
        # Example:
        #
        #   class Game
        #     include Mongoid::Document
        #     referenced_in :person
        #   end
        #
        #   class Person
        #     include Mongoid::Document
        #     references_one :game
        #   end
        def referenced_in(name, options = {}, &block)
          metadata = metadatafy(name, Referenced::In, options, &block)
          relate(name, metadata)
          reference(metadata)
        end

        # Adds a relational association from the child Document to a Document in
        # another database or collection. This differs from a normal
{'fraction_non_alphanumeric': 0.0703781512605042, 'fraction_numerical': 0.00023342670401493932, 'mean_word_length': 1.6021864561190404, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '6415118', 'n_tokens_mistral': 2190, 'n_tokens_neox': 2148, 'n_words': 793}