From ff87a91d9faab8b2ddf84662f25fb2bbfbcbd761 Mon Sep 17 00:00:00 2001 From: Benjamin Kiah Stroud <32469930+bkiahstroud@users.noreply.github.com> Date: Fri, 22 Nov 2024 17:35:02 -0800 Subject: [PATCH] add setter for Hyku.default_bulkrax_field_mappings This can be used by a hyku_knapsack app initializer to override the default Hyku application field mappings --- config/application.rb | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/config/application.rb b/config/application.rb index e0845ee54..254493035 100644 --- a/config/application.rb +++ b/config/application.rb @@ -39,11 +39,20 @@ def self.bulkrax_enabled? ActiveModel::Type::Boolean.new.cast(ENV.fetch('HYKU_BULKRAX_ENABLED', true)) end + def self.default_bulkrax_field_mappings=(value) + err_msg = 'Hyku.default_bulkrax_field_mappings must respond to #with_indifferent_access' + raise err_msg unless value.respond_to?(:with_indifferent_access) + + @default_bulkrax_field_mappings = value.with_indifferent_access + end + # This represents the default Bulkrax field mappings that new Accounts will be initialized with. # Bulkrax field mappings should not be configured within the Bulkrax initializer in Hyku. # @see lib/bulkrax/bulkrax_decorator.rb # @see https://github.com/samvera/bulkrax/wiki/Configuring-Bulkrax#field-mappings def self.default_bulkrax_field_mappings + return @default_bulkrax_field_mappings if @default_bulkrax_field_mappings.present? + default_bulkrax_fm = {} defaults = { 'abstract' => { from: ['abstract'], split: true }, @@ -111,24 +120,24 @@ def self.default_bulkrax_field_mappings } default_bulkrax_fm['Bulkrax::BagitParser'] = defaults.merge({ - # add or remove custom mappings for this parser here - }) + # add or remove custom mappings for this parser here + }) default_bulkrax_fm['Bulkrax::CsvParser'] = defaults.merge({ - # add or remove custom mappings for this parser here - }) + # add or remove custom mappings for this parser here + }) default_bulkrax_fm['Bulkrax::OaiDcParser'] = defaults.merge({ - # add or remove custom mappings for this parser here - }) + # add or remove custom mappings for this parser here + }) default_bulkrax_fm['Bulkrax::OaiQualifiedDcParser'] = defaults.merge({ - # add or remove custom mappings for this parser here - }) + # add or remove custom mappings for this parser here + }) default_bulkrax_fm['Bulkrax::XmlParser'] = defaults.merge({ - # add or remove custom mappings for this parser here - }) + # add or remove custom mappings for this parser here + }) default_bulkrax_fm.with_indifferent_access end