Skip to content

Commit

Permalink
silence deprecation warning from the rename of Module#parent to `Mo…
Browse files Browse the repository at this point in the history
…dule#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.
  • Loading branch information
agrobbin committed Sep 23, 2019
1 parent 0fbb1cd commit 2683cf0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/rails_erd/domain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 2683cf0

Please sign in to comment.