diff --git a/app/controllers/hyrax/metadata_profiles_controller.rb b/app/controllers/hyrax/metadata_profiles_controller.rb index d8ff4e3a50..ba86d4b488 100644 --- a/app/controllers/hyrax/metadata_profiles_controller.rb +++ b/app/controllers/hyrax/metadata_profiles_controller.rb @@ -26,7 +26,7 @@ def import if @flexible_schema.persisted? # After importing the profile, reload dynamic methods - Hyrax::WorkShowPresenter.reload_dynamic_methods + Hyrax::WorkShowPresenter.new(nil,nil).reload_dynamic_methods redirect_to metadata_profiles_path, notice: 'AllinsonFlexProfile was successfully created.' else redirect_to metadata_profiles_path, alert: @flexible_schema.errors.messages.to_s diff --git a/app/forms/hyrax/forms/resource_form.rb b/app/forms/hyrax/forms/resource_form.rb index 6a3a36c926..e6bebed4d0 100644 --- a/app/forms/hyrax/forms/resource_form.rb +++ b/app/forms/hyrax/forms/resource_form.rb @@ -55,7 +55,7 @@ class ResourceForm < Hyrax::ChangeSet # rubocop:disable Metrics/ClassLength def initialize(deprecated_resource = nil, resource: nil) # rubocop:disable Metrics/MethodLength if Hyrax.config.flexible? # reload dynamic methods - Hyrax::WorkShowPresenter.reload_dynamic_methods + Hyrax::WorkShowPresenter.new(nil, nil).reload_dynamic_methods singleton_class.instance_variable_set("@definitions", self.class.definitions) r = resource || deprecated_resource diff --git a/app/presenters/hyrax/flexible_schema_presenter_behavior.rb b/app/presenters/hyrax/flexible_schema_presenter_behavior.rb index dbebb65961..cc99737647 100644 --- a/app/presenters/hyrax/flexible_schema_presenter_behavior.rb +++ b/app/presenters/hyrax/flexible_schema_presenter_behavior.rb @@ -12,11 +12,12 @@ module ClassMethods def delegated_properties Hyrax::FlexibleSchema.default_properties end + end - def reload_dynamic_methods - if Hyrax.config.flexible? - Hyrax::WorkShowPresenter.new(nil, nil).define_dynamic_methods - end + def reload_dynamic_methods + if Hyrax.config.flexible? + debugger + self.class.delegate(*self.class.delegated_properties, to: :solr_document) end end end diff --git a/app/presenters/hyrax/work_show_presenter.rb b/app/presenters/hyrax/work_show_presenter.rb index 5cdf1b35b3..9fada72e2d 100644 --- a/app/presenters/hyrax/work_show_presenter.rb +++ b/app/presenters/hyrax/work_show_presenter.rb @@ -51,7 +51,7 @@ def define_dynamic_methods end end - delegate(*self.delegated_properties, to: :solr_document) if Hyrax.config.flexible? + # We cannot rely on the method missing to catch this delegation. Because # most all objects implicitly implicitly implement #to_s