<commit_before>module CallbacksAttachable
  module RegistryOwnable
    def extended(object)
      object.singleton_class.extend RegistryOwnable
    end

    def on(event, opts = {}, &callback)
      (@__callbacks__ ||= CallbackRegistry.new self).register(event, opts, callback)
    end

    def once_on(event, opts = {}, &callback)
      on(event, opts.merge(until: proc{ true }), &callback)
    end

    def on?(event)
      @__callbacks__ ? (@__callbacks__.registered? event) : false
    end

    def trigger(event, *args)
      ObjectSpace.each_object(self).each do |inst|
        trigger_for_instance(inst, event, args)
      end
    end

    def trigger_for_instance(inst, event, args)
      if superclass.respond_to? :trigger_for_instance
        superclass.trigger_for_instance(inst, event, args)
      end
      @__callbacks__ and @__callbacks__.trigger(inst, event, args)
      :triggered
    end
  end

  def self.extended(object)
    object.singleton_class.extend RegistryOwnable
  end<commit_msg>exposed callback registry as method<commit_after>module CallbacksAttachable
  module RegistryOwnable
    def extended(object)
      object.singleton_class.extend RegistryOwnable
    end

    def on(event, opts = {}, &callback)
      __callbacks__.register(event, opts, callback)
    end

    def once_on(event, opts = {}, &callback)
      on(event, opts.merge(until: proc{ true }), &callback)
    end

    def on?(event)
      @__callbacks__ ? (@__callbacks__.registered? event) : false
    end

    def trigger(event, *args)
      ObjectSpace.each_object(self).each do |inst|
        trigger_for_instance(inst, event, args)
      end
    end

    def trigger_for_instance(inst, event, args)
      if superclass.respond_to? :trigger_for_instance
        superclass.trigger_for_instance(inst, event, args)
      end
      @__callbacks__ and @__callbacks__.trigger(inst, event, args)
      :triggered
    end

    def __callbacks__
      @__callbacks__ ||= CallbackRegistry.new self
    end
  end

  def self.extended(object)
    object.singleton_class.extend RegistryOwnable
  end
{'fraction_non_alphanumeric': 0.09103977000479156, 'fraction_numerical': 0.0, 'mean_word_length': 3.2439024390243905, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3372595', 'n_tokens_mistral': 650, 'n_tokens_neox': 629, 'n_words': 149}