Skip to content

Commit

Permalink
🧹 Remove copied code
Browse files Browse the repository at this point in the history
The overrides are no longer necessary.  In reviewing the diff between
what I'm removing and what is in the `double_combo` branch; the major
change was adding an operator for the `reduce` function.  The breaking
problem was that the method signature of one of the copied methods has
changed in Hyrax 5.0.

The removal considers that Hyrax::Group is of two different classes:

- In Hyrax, it is a plain old Ruby object
- In Hyku, it is descended from ActiveRecord::Base

The two classes have different instantiation parameters.  Hence the
introduction of `Hyrax::Group.new` in this code.
  • Loading branch information
jeremyf committed Dec 19, 2023
1 parent 5655df8 commit 75d519f
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 709 deletions.
20 changes: 20 additions & 0 deletions app/models/hyrax/group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,26 @@ class Group < ApplicationRecord
before_destroy :can_destroy?
after_destroy :remove_all_members

##
# What is going on here? In Hyrax proper, the Group model is a plain old Ruby object (PORO). In
# Hyku, the {Hyrax::Group} is based on ActiveRecord.
#
# The Hyrax version instantiates with a single string parameter. Importantly, we want to re-use
# the Hyrax::Workflow::PermissionQuery logic, without re-writing it. In particular we want to
# consider the Hyrax::Workflow::PermissionQuery#scope_processing_agents_for which casts the
# group to a Sipity::Agent
#
# @see https://github.com/samvera/hyrax/blob/main/app/models/hyrax/group.rb
# @see https://github.com/samvera/hyrax/blob/main/app/services/hyrax/workflow/permission_query.rb
def self.new(*args)
# This logic path is likely coming from Hyrax specific code; in which it expects a string.
if args.size == 1 && args.first.is_a?(String)
find_by_intialize_by(name: args.first)
else
super
end
end

def self.name_prefix
DEFAULT_NAME_PREFIX
end
Expand Down
Loading

0 comments on commit 75d519f

Please sign in to comment.