Skip to content

Deprecate ActiveSupport::ProxyObject#51638

Merged
rafaelfranca merged 1 commit intorails:mainfrom
Earlopain:deprecate-as-proxy-object
Apr 22, 2024
Merged

Deprecate ActiveSupport::ProxyObject#51638
rafaelfranca merged 1 commit intorails:mainfrom
Earlopain:deprecate-as-proxy-object

Conversation

@Earlopain
Copy link
Contributor

Motivation / Background

Let's give this a try: #51632 (comment). cc @carlosantoniodasilva

This class had its uses in Ruby 1.8 times when BasicObject didn't exist yet, nowadays it is jus a wrapper.
The last internal usage was removed about 10 years ago in #16574.

Rails used to ship with a dependecy on the builder gem, which was (probably among other things) used to backport BasicObject to Ruby 1.8: 34b5767

Detail

Deprecate ActiveSupport::ProxyObject.

Additional information

There are a few uses in rails related projects. I plan to make PRs against jbuilder and activeresource if this is accepted.

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Unrelated changes should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

A historic leftover from when Ruby didn't have `BasicObject`
@rafaelfranca rafaelfranca merged commit 2323823 into rails:main Apr 22, 2024
@Earlopain Earlopain deleted the deprecate-as-proxy-object branch April 22, 2024 20:41
@carlosantoniodasilva
Copy link
Member

Thanks!

@dhh
Copy link
Member

dhh commented Apr 29, 2024

This is used by jbuilder, and BasicObject is not a drop-in replacement. Jbuilder is a default gem, and it's throwing deprecations now. That's not going to work. I don't think the deprecation here is worth it.

@dhh
Copy link
Member

dhh commented Apr 29, 2024

Fixed via https://github.com/rails/jbuilder/releases/tag/v2.12.0

@dhh
Copy link
Member

dhh commented Apr 29, 2024

(Still think we ought to be careful with deprecations like this. It may well be used in a dependency that someone does not have the power to change. But whatever for now.)

@joshuay03
Copy link
Contributor

Small follow up: #51688

@Lucaskim8
Copy link

yes

kakeru-one added a commit to Progaku-copy/progaku-archive that referenced this pull request Sep 10, 2024
Hurchan added a commit to Hurchan/prototype-rails that referenced this pull request Feb 4, 2025
zokioki added a commit to doximity/es-elasticity that referenced this pull request Aug 26, 2025
The use of `ActiveSupport::ProxyObject` was deprecated via [1] and
was fully removed in Rails 8.0. This updates the code to switch from
ProxyObject to Ruby's built-in `BasicObject` [2].

The `BasicObject` has been available in Ruby since v1.9, and given
that this gem has direct dependencies on activemodel/activesupport/
activerecord >= 5.2.0 which themselves require a minimum Ruby version
of 2.2 [3], this shouldn't introduce breaking changes for the range of
Ruby versions currently allowed by this gem. Additionally, the `raise`
method that was defined by `ProxyObject` [4] was not being leveraged
in the gem's code, so this should be a clean replacement, however,
we can define `raise` for these classes if we want to be extra
conservative with the change.

[1] rails/rails#51638
[2] https://docs.ruby-lang.org/en/3.4/BasicObject.html
[3] https://rubygems.org/gems/activemodel/versions/5.2.0
[4] https://github.com/rails/rails/blob/6f0d1ad14b92b9f5906e44740fce8b4f1c7075dc/activesupport/lib/active_support/proxy_object.rb#L13-L15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants