<commit_before>module ActiveRecord
  module IdentityMap
    extend ActiveSupport::Concern

    class << self
      attr_accessor :repositories
      attr_accessor :current_repository_name
      attr_accessor :enabled

      def current
        repositories[current_repository_name] ||= Weakling::WeakHash.new
      end

      def with_repository(name = :default, &block)
        old_repository = self.current_repository_name
        self.current_repository_name = name

        block.call(current)
      ensure
        self.current_repository_name = old_repository
      end

      def without(&block)
        old, self.enabled = self.enabled, false

        block.call
      ensure
        self.enabled = old
      end

      def get(class_name, primary_key)
        current[[class_name, primary_key]]
      end

      def add(record)
        current[[record.class.name, record.id]] = record
      end

      def remove(record)
        current.delete([record.class.name, record.id])
      end

      def clear
        current.clear
      end

      alias enabled? enabled
    end

    self.repositories ||= Hash.new
    self.current_repository_name ||= :default
    self.enabled = true<commit_msg>Use yield instead block argument.<commit_after>module ActiveRecord
  module IdentityMap
    extend ActiveSupport::Concern

    class << self
      attr_accessor :repositories
      attr_accessor :current_repository_name
      attr_accessor :enabled

      def current
        repositories[current_repository_name] ||= Weakling::WeakHash.new
      end

      def with_repository(name = :default)
        old_repository = self.current_repository_name
        self.current_repository_name = name

        yield if block_given?
      ensure
        self.current_repository_name = old_repository
      end

      def without
        old, self.enabled = self.enabled, false

        yield if block_given?
      ensure
        self.enabled = old
      end

      def get(class_name, primary_key)
        current[[class_name, primary_key]]
      end

      def add(record)
        current[[record.class.name, record.id]] = record
      end

      def remove(record)
        current.delete([record.class.name, record.id])
      end

      def clear
        current.clear
      end

      alias enabled? enabled
    end

    self.repositories ||= Hash.new
    self.current_repository_name ||= :default
    self.enabled = true
{'fraction_non_alphanumeric': 0.07045171985080813, 'fraction_numerical': 0.0, 'mean_word_length': 2.3204951856946354, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '5927849', 'n_tokens_mistral': 682, 'n_tokens_neox': 643, 'n_words': 154}