<commit_before>module Bullet
  module Detector
    class Counter < Base
      def self.clear
        @@possible_objects = nil
        @@impossible_objects = nil
      end

      def self.add_counter_cache(object, associations)
        if conditions_met?( object, associations )
          create_notification object.class, associations
        end
      end

      def self.add_possible_objects(objects)
        klazz = objects.first.class
        possible_objects[klazz] ||= []
        possible_objects[klazz] << objects
        unique(possible_objects[klazz])
      end

      def self.add_impossible_object(object)
        klazz = object.class
        impossible_objects[klazz] ||= []
        impossible_objects[klazz] << object
        impossible_objects[klazz].uniq!
      end
      
      private
      def self.create_notification( klazz, associations )
         notice = Bullet::Notification::CounterCache.new klazz, associations
         Bullet.add_notification notice
      end

      def self.unique(array)
        array.flatten!
        array.uniq!
      end

      def self.possible_objects
        @@possible_objects ||= {}
      end

      def self.impossible_objects
        @@impossible_objects ||= {}
      end

      def self.conditions_met?( object, associations )
        object_in_possible_objects?( object ) and
        object_not_in_impossible_objects?( object )
      end<commit_msg>Remove unique method - already in Base<commit_after>module Bullet
  module Detector
    class Counter < Base
      def self.clear
        @@possible_objects = nil
        @@impossible_objects = nil
      end

      def self.add_counter_cache(object, associations)
        if conditions_met?( object, associations )
          create_notification object.class, associations
        end
      end

      def self.add_possible_objects(objects)
        klazz = objects.first.class
        possible_objects[klazz] ||= []
        possible_objects[klazz] << objects
        unique(possible_objects[klazz])
      end

      def self.add_impossible_object(object)
        klazz = object.class
        impossible_objects[klazz] ||= []
        impossible_objects[klazz] << object
        impossible_objects[klazz].uniq!
      end
      
      private
      def self.create_notification( klazz, associations )
         notice = Bullet::Notification::CounterCache.new klazz, associations
         Bullet.add_notification notice
      end

      def self.possible_objects
        @@possible_objects ||= {}
      end

      def self.impossible_objects
        @@impossible_objects ||= {}
      end

      def self.conditions_met?( object, associations )
        object_in_possible_objects?( object ) and
        object_not_in_impossible_objects?( object )
      end
{'fraction_non_alphanumeric': 0.07619738751814223, 'fraction_numerical': 0.0, 'mean_word_length': 2.3745410036719705, 'pattern_counts': {'":': 0, '<': 13, '<?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': '4529041', 'n_tokens_mistral': 744, 'n_tokens_neox': 730, 'n_words': 157}