Skip to content

Commit

Permalink
make #reload_dynamic_methods an instance method
Browse files Browse the repository at this point in the history
  • Loading branch information
ShanaLMoore committed Jul 10, 2024
1 parent 4f24cbd commit 31ab8e3
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/controllers/hyrax/metadata_profiles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/forms/hyrax/forms/resource_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions app/presenters/hyrax/flexible_schema_presenter_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ 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?
self.class.delegate(*self.class.delegated_properties, to: :solr_document)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/hyrax/work_show_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 31ab8e3

Please sign in to comment.