Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🧹 Clean up services #2109

Merged
merged 2 commits into from
Dec 22, 2023
Merged

🧹 Clean up services #2109

merged 2 commits into from
Dec 22, 2023

Conversation

kirkkwang
Copy link
Collaborator

This commit will reconcile the services that are overrides for Hyrax with the Hyrax 5.0.0rc2 version. There were a number of overrides that were changed to the decorator pattern.

Ref:

This commit will reconcile the services that are overrides for Hyrax
with the Hyrax 5.0.0rc2 version.  There were a number of overrides that
were changed to the decorator pattern.
@kirkkwang kirkkwang added the patch-ver for release notes label Dec 21, 2023
@@ -209,7 +118,7 @@ def self.create_user_collection_type
# If calling from Abilities, pass the ability.
# If you try to get the ability from the user, you end up in an infinite loop.
# rubocop:disable Metrics/MethodLength
def self.add_default_participants(collection_type_id)
def add_default_participants(collection_type_id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd feel better if this were in a submodule ClassMethods

Reading this module it would be easy to think it's an instance method. But we prepend it to a singleton class.

end
end

Hyrax::ThumbnailPathService.singleton_class.send(:prepend, Hyrax::ThumbnailPathServiceDecorator)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Hyrax::ThumbnailPathService.singleton_class.send(:prepend, Hyrax::ThumbnailPathServiceDecorator)
Hyrax::ThumbnailPathService.singleton_class.send(:prepend, Hyrax::WorkThumbnailPathServiceDecorator)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the above change? We can get rid of another module and reduce duplication of knowledge.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, are you suggesting to remove the app/services/hyrax/thumbnail_path_service_decorator.rb and put Hyrax::ThumbnailPathService.singleton_class.send(:prepend, Hyrax::WorkThumbnailPathServiceDecorator) in app/services/hyrax/work_thumbnail_path_service_decorator.rb?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think my concern with that is the coupling of both of services. In the super Hyrax actually has two different returns

WorkThumbnailPathService => ActionController::Base.helpers.image_path 'work.png'
and
ThumbnailPathService => ActionController::Base.helpers.image_path 'default.png'

If in an event that we want to change Hyku's thumbnail path and work thumbnail path then it would be easier to find and already set up. But I'm not holding on to this idea too strongly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm alright with what you have. But consider, your tests show what super means and the code looks like duplication (because it is; it just overlays different things, which is the nature of polymorphism/encapsulation)

This commit addresses comments from the review but one thing that is of
note is loading the I18n translations in the application.rb file.  We
needed this because our decorators load prior to I18n loads the locales
in our config/locales directory for them to use so we were getting
missing translations.
@kirkkwang kirkkwang merged commit 357da53 into hyrax-5-upgrade Dec 22, 2023
2 of 3 checks passed
@kirkkwang kirkkwang deleted the hyrax-5-clean-up-services branch December 22, 2023 14:19
@kirkkwang kirkkwang mentioned this pull request Jan 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch-ver for release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants