lib/httpx/options.rb in httpx-1.2.1 vs lib/httpx/options.rb in httpx-1.2.2

- old
+ new

@@ -45,17 +45,17 @@ keep_alive_timeout: KEEP_ALIVE_TIMEOUT, read_timeout: READ_TIMEOUT, write_timeout: WRITE_TIMEOUT, request_timeout: REQUEST_TIMEOUT, }, + :headers_class => Class.new(Headers), :headers => {}, :window_size => WINDOW_SIZE, :buffer_size => BUFFER_SIZE, :body_threshold_size => MAX_BODY_THRESHOLD_SIZE, :request_class => Class.new(Request), :response_class => Class.new(Response), - :headers_class => Class.new(Headers), :request_body_class => Class.new(Request::Body), :response_body_class => Class.new(Response::Body), :connection_class => Class.new(Connection), :options_class => Class.new(self), :transport => nil, @@ -152,11 +152,11 @@ def option_base_path(value) String(value) end def option_headers(value) - Headers.new(value) + headers_class.new(value) end def option_timeout(value) Hash[value] end @@ -340,15 +340,14 @@ def do_initialize(options = {}) defaults = DEFAULT_OPTIONS.merge(options) defaults.each do |k, v| next if v.nil? - begin - value = __send__(:"option_#{k}", v) - instance_variable_set(:"@#{k}", value) - rescue NoMethodError - raise Error, "unknown option: #{k}" - end + option_method_name = :"option_#{k}" + raise Error, "unknown option: #{k}" unless respond_to?(option_method_name) + + value = __send__(option_method_name, v) + instance_variable_set(:"@#{k}", value) end end end end