<commit_before>module Announcr
  class EventScope
    attr_reader :namespace, :data, :event_name

    def initialize(event_name, opts = {})
      @event_name = event_name
      @namespace = opts.fetch(:namespace)
      @data = opts.fetch(:data, {})

      @options = opts

      @backends = @namespace.all_backends
      @default_backend = @namespace.default_backend

      setup_proxy_methods!
    end

    def key_for(key)
      @namespace.key_for(key)
    end

    def event_name_key
      key_for(event_name)
    end

    private

    def setup_proxy_methods!
      singleton = class << self; self end

      @backends.each_pair do |name, backend|
        if @default_backend == name || @backends.size == 1
          backend.class.proxy_methods.each do |m|
            singleton.send(:define_method, m) do |*args|
              backend.send(m, *args)
            end
          end
        end

        singleton.send(:define_method, name) do
          backend
        end
      end
    end
  end
end
<commit_msg>Bugfix: EventScope#key_for takes multiple parts<commit_after>module Announcr
  class EventScope
    attr_reader :namespace, :data, :event_name

    def initialize(event_name, opts = {})
      @event_name = event_name
      @namespace = opts.fetch(:namespace)
      @data = opts.fetch(:data, {})

      @options = opts

      @backends = @namespace.all_backends
      @default_backend = @namespace.default_backend

      setup_proxy_methods!
    end

    def key_for(*keys)
      @namespace.key_for(keys)
    end

    def event_name_key
      key_for(event_name)
    end

    private

    def setup_proxy_methods!
      singleton = class << self; self end

      @backends.each_pair do |name, backend|
        if @default_backend == name || @backends.size == 1
          backend.class.proxy_methods.each do |m|
            singleton.send(:define_method, m) do |*args|
              backend.send(m, *args)
            end
          end
        end

        singleton.send(:define_method, name) do
          backend
        end
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.09038182696955051, 'fraction_numerical': 0.0009666505558240696, 'mean_word_length': 2.1699846860643186, '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': '1047157', 'n_tokens_mistral': 643, 'n_tokens_neox': 623, 'n_words': 146}