<commit_before>class Batch

    # Manages batch event notifications and subscriptions
    class Events

        # Records subscription details
        class Subscription

            attr_reader :source, :callback, :raise_on_error


            def initialize(source, options, callback)
                @source = source
                @raise_on_error = options.fetch(:raise_on_error, true)
                @callback = callback
            end


            def ===(obj)
                @source.nil? ||             # Nil source means match any source
                    (@source == obj) ||     # Source is obj
                    (@source === obj) ||    # Source is same class as obj
                    (@source.instance_of?(Module) && obj.instance_of?(Class) && obj.include?(@source)) ||   # Source is a module included by obj
                    (obj.class.include(ActsAsJob) && @source === obj.job)   # Source is a job, and obj is an instance of that job
            end

        end



        class << self

            # @param source [Object] The source of the event
            # @param event [String] The name of the event
            # @return [Boolean] whether there are any subscribers for the specified
            #   event.
            def has_subscribers?(source, event)
                subscribers.has_key?(event) && subscribers[event].size > 0 &&
                    subscribers[event].find{ |sub| sub === source }
            end


            # Setup a subscription for a particular event. When a matching event
            # occurs, the supplied block will be called with the published
            # arguments.
            #
            # @param source [Object] The type of source object from which to
            #   listen for events.
            # @param event [String] The name of the event to subscribe to.
            # @param options [Hash] An options hash defining optional settings
            #   for the subscription.
            # @option options [Fixnum] :position The position within the list to
            #   insert the subscriber. Default is to add to the end of the list.
            # @param callback [Proc] A block to be invoked when the event occurs.<commit_msg>Fix bug in event matching<commit_after>class Batch

    # Manages batch event notifications and subscriptions
    class Events

        # Records subscription details
        class Subscription

            attr_reader :source, :callback, :raise_on_error


            def initialize(source, options, callback)
                @source = source
                @raise_on_error = options.fetch(:raise_on_error, true)
                @callback = callback
            end


            def ===(obj)
                @source.nil? ||             # Nil source means match any source
                    (@source == obj) ||     # Source is obj
                    (@source === obj) ||    # Source is same class as obj
                    (@source.instance_of?(Module) && obj.instance_of?(Class) && obj.include?(@source)) ||   # Source is a module included by obj
                    (obj.class.include?(ActsAsJob) && @source === obj.job)   # Source is a job, and obj is an instance of that job
            end

        end



        class << self

            # @param source [Object] The source of the event
            # @param event [String] The name of the event
            # @return [Boolean] whether there are any subscribers for the specified
            #   event.
            def has_subscribers?(source, event)
                subscribers.has_key?(event) && subscribers[event].size > 0 &&
                    subscribers[event].find{ |sub| sub === source }
            end


            # Setup a subscription for a particular event. When a matching event
            # occurs, the supplied block will be called with the published
            # arguments.
            #
            # @param source [Object] The type of source object from which to
            #   listen for events.
            # @param event [String] The name of the event to subscribe to.
            # @param options [Hash] An options hash defining optional settings
            #   for the subscription.
            # @option options [Fixnum] :position The position within the list to
            #   insert the subscriber. Default is to add to the end of the list.
            # @param callback [Proc] A block to be invoked when the event occurs.
{'fraction_non_alphanumeric': 0.07702733227919584, 'fraction_numerical': 0.00045177320984865596, 'mean_word_length': 1.7049480757483202, 'pattern_counts': {'":': 0, '<': 7, '<?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': '2442114', 'n_tokens_mistral': 1074, 'n_tokens_neox': 1016, 'n_words': 431}