Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid Hash monkey patch when loading DeepMerge #314

Closed
davidgoldelocks opened this issue Jan 10, 2022 · 2 comments · Fixed by #342
Closed

avoid Hash monkey patch when loading DeepMerge #314

davidgoldelocks opened this issue Jan 10, 2022 · 2 comments · Fixed by #342
Milestone

Comments

@davidgoldelocks
Copy link

followup to #120

DeepMerge can be loaded in 3 different ways:

  1. only the core library
  2. the core library + the default Hash monkey patch
  3. the core library + an alternative Hash monkey patch that does not conflict with ActiveSupport

Config is currently using the 2nd variant:

require 'deep_merge'

However, Config does not actually use the monkey patch, so it should switch to the 1st variant:

require 'deep_merge/core'

This is conceptually cleaner and prevents the conflict with ActiveSupport.

@davidgoldelocks
Copy link
Author

If end users want either of the monkey patches, they can require them directly:

require 'deep_merge/deep_merge_hash'
require 'deep_merge/rails_compat'

@cjlarose
Copy link
Member

cjlarose commented Jan 11, 2022

I'm open to a PR with this change. I'll likely bump the major version, though, since it's possible someone is implicitly depending on the Hash monkey patch in their application.

jonathanhefner added a commit to jonathanhefner/rubyconfig-config that referenced this issue Oct 2, 2023
`config` uses `DeepMerge.deep_merge!` instead of `Hash#deep_merge!`, so
monkey patching `Hash` is unnecessary.  Furthermore, DeepMerge's `Hash`
monkey patch is not compatible with Rails 7.1 (see [rails#49457][]).

This commit changes `require 'deep_merge'` to `require 'deep_merge/core'`
so that DeepMerge's `Hash` monkey patch is no longer loaded.  Users who
rely the monkey patch can load it manually via
`require 'deep_merge/deep_merge_hash'`.

Closes rubyconfig#314.

[rails#49457]: rails/rails#49457
jonathanhefner added a commit to jonathanhefner/rubyconfig-config that referenced this issue Oct 3, 2023
`config` uses `DeepMerge.deep_merge!` instead of `Hash#deep_merge!`, so
monkey patching `Hash` is unnecessary.  Furthermore, DeepMerge's `Hash`
monkey patch is not compatible with Rails 7.1 (see [rails#49457][]).

This commit changes `require 'deep_merge'` to `require 'deep_merge/core'`
so that DeepMerge's `Hash` monkey patch is no longer loaded.  Users who
rely on the monkey patch can load it manually via
`require 'deep_merge/deep_merge_hash'`.

Closes rubyconfig#314.

[rails#49457]: rails/rails#49457
@pkuczynski pkuczynski added this to the 5.0.0 milestone Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

3 participants