Repository navigation
Convert ConnectionOptions to BaseOptions (#1652) - #1738
Merged
Merged
Conversation
ConnectionOptions was the last Struct-based options class before Env. It now inherits from BaseOptions, like RequestOptions and SSLOptions. - request, ssl and proxy are coerced by .from, #update and #merge. A falsy value means "not set", like the legacy #update, so ssl: false no longer reaches SSLOptions.from, which raises for false. - request and ssl readers still assign a new instance when none is set, and builder_class still defaults to RackBuilder. - No Faraday::StructCompat: no adapter or middleware in awesome-faraday uses ConnectionOptions or Faraday.default_connection_options. Faraday.new now merges default_connection_options with BaseOptions#merge, so nil values no longer overwrite the defaults. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
28 tasks
The legacy #update skipped a falsy request, ssl or proxy and kept the current value. The first conversion reset the member instead, so update(request: false) dropped the request options. ConnectionOptions now skips false for its coerced members, which also lets COERCIONS use the classes instead of lambdas. Also from the review of #1738: - Document that proxy can be nil and that to_hash includes the request, ssl and builder_class defaults, and test the latter. - Rename the utils_spec examples that still called ConnectionOptions an Options Struct. - Test Utils.deep_merge with a legacy Options source again: the renamed example no longer covered that branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5 of 7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1652. Part of #1647 (Phase 3, v2.x.2).
What changed
ConnectionOptionsnow inherits fromBaseOptionsinstead ofOptions.request,sslandproxyare coerced toRequestOptions,SSLOptionsandProxyOptionsby.from,#updateand#merge.falsemeans "not set" for these members, like the legacy#update: it is skipped and the current value stays. Thusssl: falsedoes not reachSSLOptions.from, which raisesArgumentErrorforfalse.requestandsslreaders assign a new instance when none is set.builder_classdefaults toRackBuilder.new_builderis unchanged. Because of these defaults,to_hashalways includesrequest,sslandbuilder_class.proxyis now coerced too (the Struct did not do this). Thus aProxyOptionsvalue stays one whenFaraday.newcopies the options.Faraday::StructCompatis not included. No adapter or middleware in awesome-faraday usesConnectionOptionsorFaraday.default_connection_options(checked for Convert ProxyOptions, RequestOptions, SSLOptions to BaseOptions (#1651) #1733).Behaviour changes for user code
opts[:url],opts[:url] = x,to_h,each,membersNoMethodError, use the accessorsopts == otherConnectionOptions.new(req, proxy)(positional)Faraday.new(url, headers: nil)with default headersniloverwrites the defaultConnectionOptions.from(proxy: 'http://p')proxystays a Stringproxyis aProxyOptionsTests
spec/faraday/options/connection_options_spec.rb(17 examples): coercion,falsevalues,to_hashdefaults, deep copies, deep merge,builder_class/new_builder,Faraday.default_connection_options.spec/faraday/utils_spec.rbtestsUtils.deep_mergewith a legacyOptionssource again.🤖 Generated with Claude Code