Skip to content

Instantly share code, notes, and snippets.

@ansonhoyt
Last active Apr 20, 2021
Embed
What would you like to do?
# ...
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
# TODO: remove once gems no longer need it. See required file for details.
# Patches Rails before initializing Gems. Also covers rake tasks that don't depend on :environment.
if Rails.gem_version >= Gem::Version.new('6.1') # Forward-port methods removed in 6.1
require_relative "../lib/extensions/core_ext/module/introspection"
end
# ...
# frozen_string_literal: true
# Restores `Module#parent_name`, `Module#parent` and `Module#parents`.
# Removed in Rails 6.1 by https://github.com/rails/rails/commit/167b4153cac0069a21e0bb9689cb16f34f6abbaa
#
# Still required by exception_notifier:
# - https://github.com/smartinez87/exception_notification/pull/504
class Module
def parent_name
ActiveSupport::Deprecation.warn(<<-MSG.squish)
`Module#parent_name` has been renamed to `module_parent_name`.
`parent_name` is deprecated and will be removed in Rails 6.1.
MSG
module_parent_name
end
def parent
ActiveSupport::Deprecation.warn(<<-MSG.squish)
`Module#parent` has been renamed to `module_parent`.
`parent` is deprecated and will be removed in Rails 6.1.
MSG
module_parent
end
def parents
ActiveSupport::Deprecation.warn(<<-MSG.squish)
`Module#parents` has been renamed to `module_parents`.
`parents` is deprecated and will be removed in Rails 6.1.
MSG
module_parents
end
end
if Gem.loaded_specs['exception_notification'].version > Gem::Version.new('4.4.3')
ActiveSupport::Deprecation.warn "exception_notification has been updated, so this patch may no longer be necessary"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment