<commit_before>module Hawk
  module Model

    ##
    # Fetches models from the remote HTTP endpoint.
    #
    module Connection
      def self.included(base)
        base.extend ClassMethods
      end

      def initialize(attributes = {}, http_options = {})
        @http_options = http_options || {}

        super
      end
      attr_reader :http_options

      def connection
        self.class.connection
      end

      module ClassMethods
        def connection
          @_connection ||= begin
            raise Error::Configuration, "URL for #{name} is not yet set" unless url
            raise Error::Configuration, "Please set the client_name"     unless client_name

            options = self.http_options.dup
            headers = (options[:headers] ||= {})

            if headers.key?('User-Agent')
              raise Error::Configuration, "Please set the User-Agent header through client_name"
            end

            headers['User-Agent'] = self.client_name

            Hawk::HTTP.new(url, options)
          end
        end

        def url(url = nil)<commit_msg>Add .options() shorthand to set HTTP options on a chain<commit_after>module Hawk
  module Model

    ##
    # Fetches models from the remote HTTP endpoint.
    #
    module Connection
      def self.included(base)
        base.extend ClassMethods
      end

      def initialize(attributes = {}, http_options = {})
        @http_options = http_options || {}

        super
      end
      attr_reader :http_options

      def connection
        self.class.connection
      end

      module ClassMethods
        def connection
          @_connection ||= begin
            raise Error::Configuration, "URL for #{name} is not yet set" unless url
            raise Error::Configuration, "Please set the client_name"     unless client_name

            options = self.http_options.dup
            headers = (options[:headers] ||= {})

            if headers.key?('User-Agent')
              raise Error::Configuration, "Please set the User-Agent header through client_name"
            end

            headers['User-Agent'] = self.client_name

            Hawk::HTTP.new(url, options)
          end
        end

        def options(opts)
          where(options: opts)
        end

        def url(url = nil)
{'fraction_non_alphanumeric': 0.08181026979982593, 'fraction_numerical': 0.0, 'mean_word_length': 1.8918238993710692, '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': '2824491', 'n_tokens_mistral': 591, 'n_tokens_neox': 567, 'n_words': 175}