Skip to content

Commit

Permalink
add setter for Hyku.default_bulkrax_field_mappings
Browse files Browse the repository at this point in the history
This can be used by a hyku_knapsack app initializer to override the
default Hyku application field mappings
  • Loading branch information
bkiahstroud committed Nov 23, 2024
1 parent da23315 commit ff87a91
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ff87a91

Please sign in to comment.