<commit_before>module Requestable

  def self.included(mod)
    mod.module_eval do
      extend(ClassMethods)
      include(InstanceMethods)
    end
  end

  module ClassMethods
    def requests
      @requests ||= {}
    end

    def define_request(name, &block)
      requests[name] = block
    end
  end

  module InstanceMethods
    def prepare_request(name, *args)
      block = self.class.requests[name]
      options = self.instance_exec(*args, &block)
      Request.new(@client, options)
    end

    def request(name, *args)
      prepare_request(name, *args).exec
    end
  end
<commit_msg>sensible error on call for nonexistent request<commit_after>module Requestable

  def self.included(mod)
    mod.module_eval do
      extend(ClassMethods)
      include(InstanceMethods)
    end
  end

  module ClassMethods
    def requests
      @requests ||= {}
    end

    def define_request(name, &block)
      requests[name] = block
    end
  end

  module InstanceMethods
    def prepare_request(name, *args)
      if block = self.class.requests[name]
        options = self.instance_exec(*args, &block)
        Request.new(@client, options)
      else
        raise ArgumentError, "No request has been defined for #{name.inspect}"
      end
    end

    def request(name, *args)
      prepare_request(name, *args).exec
    end
  end

{'fraction_non_alphanumeric': 0.08582089552238806, 'fraction_numerical': 0.0, 'mean_word_length': 2.684065934065934, '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': '1830276', 'n_tokens_mistral': 407, 'n_tokens_neox': 394, 'n_words': 104}