From 2683cf049c6a9aee88f6e08c3582cd4e03a113c8 Mon Sep 17 00:00:00 2001 From: Alex Robbin Date: Sun, 22 Sep 2019 21:57:27 -0400 Subject: [PATCH] silence deprecation warning from the rename of `Module#parent` to `Module#module_parent` Rails 6 deprecated `Module#parent` and friends in rails/rails#34051, replacing them with a `module_*`-prefix naming scheme. This checks to see if `module_parent` is defined, using it if it's available. --- lib/rails_erd/domain.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/rails_erd/domain.rb b/lib/rails_erd/domain.rb index f292409b..bf836b89 100644 --- a/lib/rails_erd/domain.rb +++ b/lib/rails_erd/domain.rb @@ -49,7 +49,13 @@ def initialize(models = [], options = {}) # Returns the domain model name, which is the name of your Rails # application or +nil+ outside of Rails. def name - defined? Rails and Rails.application and Rails.application.class.parent.name + return unless defined?(Rails) && Rails.application + + if Rails.application.class.respond_to?(:module_parent) + Rails.application.class.module_parent.name + else + Rails.application.class.parent.name + end end # Returns all entities of your domain model.