From f70459e723e54c53c76f15768acc90695479c938 Mon Sep 17 00:00:00 2001 From: Tom Johnson Date: Fri, 18 Oct 2019 14:44:16 -0700 Subject: [PATCH] Deprecate `PowerConverter` based `to_polymorphic_type` This was very sparsely used. Instead of porting it elsewhere, just cast the one caller individually. If folks are using this downstream (I'd guess they aren't) we could consider putting this mapper at the top `Hyrax` level, or somewhere similar. --- app/conversions/power_converters/polymorphic_type.rb | 1 + app/models/sipity/workflow_action.rb | 2 +- app/services/hyrax/workflow/permission_query.rb | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/conversions/power_converters/polymorphic_type.rb b/app/conversions/power_converters/polymorphic_type.rb index 219b1a21f5..5506eb8429 100644 --- a/app/conversions/power_converters/polymorphic_type.rb +++ b/app/conversions/power_converters/polymorphic_type.rb @@ -1,4 +1,5 @@ PowerConverter.define_conversion_for(:polymorphic_type) do |input| + Deprecation.warn('PowerConverter is deprecated. Use `.base_class` instead') if input.respond_to?(:base_class) input.base_class elsif input.is_a?(ActiveRecord::Base) diff --git a/app/models/sipity/workflow_action.rb b/app/models/sipity/workflow_action.rb index f50acc3dfd..fd40258890 100644 --- a/app/models/sipity/workflow_action.rb +++ b/app/models/sipity/workflow_action.rb @@ -34,7 +34,7 @@ def self.name_for(input, &block) when Sipity::WorkflowAction input.name end - Sipity.handle_conversion(result, &block) + Sipity.handle_conversion(input, result, :to_sipity_action_name, &block) end end end diff --git a/app/services/hyrax/workflow/permission_query.rb b/app/services/hyrax/workflow/permission_query.rb index 263c130a90..f2886a985b 100644 --- a/app/services/hyrax/workflow/permission_query.rb +++ b/app/services/hyrax/workflow/permission_query.rb @@ -242,7 +242,7 @@ def scope_entities_for_the_user(user:) def scope_users_for_entity_and_roles(entity:, roles:) entity = Sipity::Entity(entity) role_ids = Array.wrap(roles).map { |role| Sipity::Role(role).id } - user_polymorphic_type = PowerConverter.convert_to_polymorphic_type(::User) + user_polymorphic_type = ::User.base_class user_table = ::User.arel_table agent_table = Sipity::Agent.arel_table