<commit_before>module ActiveMongoid
  module Associations
    module RecordRelation
      module Referenced
        class One < Associations::One

          def initialize(base, target, metadata)
            init(base, target, metadata) do
              bind_one
            end
          end

          def substitute(replacement)
            unbind_one
            if base.persisted?
              if __metadata__.destructive?
                send(__metadata__.dependent)
              else
                save if persisted?
              end
            end
            One.new(base, replacement, __metadata__) if replacement
          end

          private

          def binding
            Bindings::One.new(base, target, __metadata__)
          end

          class << self

            def stores_foreign_key?
              false
            end

            def foreign_key(name)
              "#{name}#{foreign_key_suffix}"
            end

            def foreign_key_default
              nil
            end

            def foreign_key_suffix
              "_id"
            end

            def primary_key_default
              "_id"
            end

            def macro
              :has_one_record
            end

            def builder(base, meta, object)
              ActiveMongoid::Associations::Builders::One.new(base, meta, object)
            end

            def criteria(metadata, object, type = nil)
              metadata.klass.where(metadata.foreign_key => object.to_s)
            end

          end<commit_msg>fixed method<commit_after>module ActiveMongoid
  module Associations
    module RecordRelation
      module Referenced
        class One < Associations::One

          def initialize(base, target, metadata)
            init(base, target, metadata) do
              bind_one
            end
          end

          def substitute(replacement)
            unbind_one
            if base.persisted?
              if __metadata__.destructive?
                send(__metadata__.dependent)
              else
                save if persisted?
              end
            end
            One.new(base, replacement, __metadata__) if replacement
          end

          private

          def binding
            Bindings::One.new(base, target, __metadata__)
          end

          class << self

            def stores_foreign_key?
              false
            end

            def foreign_key(name)
              "#{name}#{foreign_key_suffix}"
            end

            def foreign_key_default
              nil
            end

            def foreign_key_suffix
              "_id"
            end

            def primary_key_default
              "_id"
            end

            def macro
              :has_one_record
            end

            def builder(base, meta, object)
              ActiveMongoid::Associations::Builders::One.new(base, meta, object)
            end

            def criteria(metadata, object, type = nil)
              metadata.klass.where(metadata.foreign_key => object)
            end

          end
{'fraction_non_alphanumeric': 0.05271668822768435, 'fraction_numerical': 0.0, 'mean_word_length': 1.1920623671155208, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, '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': '1115466', 'n_tokens_mistral': 748, 'n_tokens_neox': 705, 'n_words': 184}