Update Utils.deep_merge! to Support OptionsLike
Phase: 1 - Foundation
Release Target: v2.x.0
Tracking Issue: #1647
RFC: docs/options-detach-plan.md
Overview
Update Faraday::Utils.deep_merge! to recognize OptionsLike objects instead of hardcoding checks for Faraday::Options. This enables both legacy Options and new BaseOptions subclasses to work with deep merging.
Current Code
File: lib/faraday/utils.rb (line 103)
if value.is_a?(Hash) && (target[key].is_a?(Hash) || target[key].is_a?(Options))
Proposed Change
if value.is_a?(Hash) && (target_value.is_a?(Hash) || target_value.is_a?(Faraday::OptionsLike))
Why: This allows deep_merge! to work uniformly with:
- Legacy
Faraday::Options (which will include OptionsLike)
- New
BaseOptions subclasses (which include OptionsLike)
- Any future Options-like classes
Implementation Tasks
Files to Modify
lib/faraday/utils.rb (line ~103)
lib/faraday/options.rb (add include OptionsLike)
spec/faraday/utils_spec.rb (add/update tests)
Acceptance Criteria
Dependencies
Backward Compatibility
This is backward compatible because:
- Legacy
Options will include OptionsLike, so is_a?(OptionsLike) checks will pass
- The change broadens support rather than restricting it
- All existing deep_merge! behavior preserved
Testing Strategy
Create a test BaseOptions subclass in the spec to validate:
class TestOptions < Faraday::BaseOptions
MEMBERS = [:foo, :bar].freeze
COERCIONS = {}.freeze
attr_accessor :foo, :bar
end
# Test that deep_merge! works with this class
Update Utils.deep_merge! to Support OptionsLike
Phase: 1 - Foundation
Release Target: v2.x.0
Tracking Issue: #1647
RFC: docs/options-detach-plan.md
Overview
Update
Faraday::Utils.deep_merge!to recognizeOptionsLikeobjects instead of hardcoding checks forFaraday::Options. This enables both legacyOptionsand newBaseOptionssubclasses to work with deep merging.Current Code
File:
lib/faraday/utils.rb(line 103)Proposed Change
Why: This allows deep_merge! to work uniformly with:
Faraday::Options(which will includeOptionsLike)BaseOptionssubclasses (which includeOptionsLike)Implementation Tasks
Utils.deep_merge!implementationOptionsLikeinstead ofOptionsFaraday::Optionsto includeOptionsLikemodule (for backward compatibility)spec/faraday/utils_spec.rbcovering:Files to Modify
lib/faraday/utils.rb(line ~103)lib/faraday/options.rb(addinclude OptionsLike)spec/faraday/utils_spec.rb(add/update tests)Acceptance Criteria
deep_merge!works with bothOptionsandBaseOptionssubclassesDependencies
Backward Compatibility
This is backward compatible because:
Optionswill includeOptionsLike, sois_a?(OptionsLike)checks will passTesting Strategy
Create a test
BaseOptionssubclass in the spec to validate: