rubyconfig / config

Easiest way to add multi-environment yaml settings to Rails, Sinatra, Padrino and other Ruby projects.
Other
2.1k stars 230 forks source link

avoid Hash monkey patch when loading DeepMerge #314

Closed davidgoldelocks closed 11 months ago

davidgoldelocks commented 2 years ago

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: https://github.com/rubyconfig/config/blob/9c35a5d579e548b2c439cd4defb247baf51dbb64/lib/config.rb#L9

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 commented 2 years ago

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 commented 2 years ago

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.