<commit_before>require "disclosure/engine"
require "disclosure/configuration"

module Disclosure
  class << self
    attr_accessor :configuration
  end

  def self.configuration
    @configuration ||= Configuration.new
  end
<commit_msg>Add two new methods: 1. bootstrap!, to add required methods to notifiable models 2. react_to!, that accepts a model as an argument and reacts to any    events on that model, if any<commit_after>require "disclosure/engine"
require "disclosure/configuration"

module Disclosure
  class << self
    attr_accessor :configuration
  end

  def self.bootstrap!
    Disclosure.configuration.notifier_classes.each do |klass|
      unless klass.methods.include?(:notifiable_actions)
        klass.define_method(:notifiable_actions) do
          raise ::NotImplementedError, "Notifiable actions must be defined in #{klass.name}."
        end
      end

      klass.notifiable_actions.each do |action|
        unless klass.instance_methods.include?(:"#{action}?")
          klass.define_method(:"#{action}?") do
            raise ::NotImplementedError, "#{action}? must be defined in #{klass}."
          end
        end
      end
    end
  end

  def self.react_to!(model)
    unless Disclosure.configuration.notifier_classes.include?(model.class) 
      return nil
    end

    Disclosure::Rule.where(
      :notifier_class => model.class.name,
      :owner_id => model.send("#{Disclosure.configuration.owner_class.underscore}_id")
    ).each do |rule|
      next if !model.send("#{rule.action}?")
      rule.react!(model)
    end
  end

  def self.configuration
    @configuration ||= Configuration.new
  end

{'fraction_non_alphanumeric': 0.1001832620647526, 'fraction_numerical': 0.0012217470983506415, 'mean_word_length': 3.3105263157894735, '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': '63953', 'n_tokens_mistral': 471, 'n_tokens_neox': 467, 'n_words': 124}