From 0ee1b477842c0aedae9d22277ecee8129a8b8193 Mon Sep 17 00:00:00 2001 From: Jeremy Friesen Date: Mon, 5 Feb 2024 15:42:34 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20Hyrax::ChangeSet.inspect?= =?UTF-8?q?=20method?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prior to this, there was no reference to `model_class` meaning that `Hyrax::ChangeSet.inspect` would raise an exception. We need the binding of the `resource_class`, which is available during the creation of the class but not afterwards. In other words, by using the `define_singleton_method` we can leverage the provided `resource_class` as a bound value for the return value of `.inspect`. --- app/models/hyrax/change_set.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/hyrax/change_set.rb b/app/models/hyrax/change_set.rb index 727f327152..92c20736c5 100644 --- a/app/models/hyrax/change_set.rb +++ b/app/models/hyrax/change_set.rb @@ -21,8 +21,8 @@ def self.ChangeSet(resource_class) ## # @return [String] - def self.inspect - return "Hyrax::ChangeSet(#{model_class})" if name.blank? + define_singleton_method :inspect do + return "Hyrax::ChangeSet(#{resource_class})" if name.blank? super end end