<commit_before>class Etcdv3
  class Request

    attr_reader :metacache

    def initialize(hostname, credentials, metadata, metacache)
      @hostname = hostname
      @credentials = credentials
      @metadata = metadata
      @metacache = metacache
    end

    def handle(interface, method, method_args=[])
      interface = resolve_interface(interface)
      interface.send(method, *method_args)
    end

    private

    def resolve_interface(interface)
      self.send(interface)
    end

    def auth
      @auth ||= Etcdv3::Auth.new(@hostname, @credentials, @metadata)
    end

    def kv
      @kv ||= Etcdv3::KV.new(@hostname, @credentials, @metadata)
    end

    def maintenance
      @maintenance ||= Etcdv3::Maintenance.new(@hostname, @credentials, @metadata)
    end

    def lease
      @lease ||= Etcdv3::Lease.new(@hostname, @credentials, @metadata)
    end

    def watch
      @watch ||= Etcdv3::Watch.new(@hostname, @credentials, @metadata)
    end

  end
end<commit_msg>Refactoring the requests file a bit.<commit_after>class Etcdv3
  class Request

    attr_reader :metacache

    def initialize(hostname, credentials, metadata, metacache='')
      @handlers ||= handler_map(hostname, credentials, metadata)
      @metacache = metacache
    end

    def handle(stub, method, method_args=[])
      @handlers.fetch(stub).send(method, *method_args)
    end

    private

    def handler_map(hostname, credentials, metadata)
      Hash[
        handler_constants.map do |key, klass|
          [key, klass.new(hostname, credentials, metadata)]
        end
      ]
    end

    def handler_constants
      {
        auth: Etcdv3::Auth,
        kv: Etcdv3::KV,
        maintenance: Etcdv3::Maintenance,
        lease: Etcdv3::Lease,
        watch: Etcdv3::Watch
      }
    end
  end
end
{'fraction_non_alphanumeric': 0.10254988913525499, 'fraction_numerical': 0.0066518847006651885, 'mean_word_length': 2.8, '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': '5682134', 'n_tokens_mistral': 568, 'n_tokens_neox': 568, 'n_words': 131}