Skip to content

Commit

Permalink
♻️ Move method and remove single instance definition
Browse files Browse the repository at this point in the history
I'm unclear why we were defining methods on the conf instance;
especially given that these exist on the configuration.

With this refactor, we're favoring using the Configuration object as the
container.
  • Loading branch information
jeremyf committed Mar 13, 2024
1 parent db6cacf commit e1c5e0d
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions lib/bulkrax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,10 @@ module Bulkrax
# @api public
class Configuration
attr_accessor :api_definition,
:curation_concerns,
:default_field_mapping,
:default_work_type,
:export_path,
:field_mappings,
:file_model_class,
:generated_metadata_mapping,
:import_path,
:multi_value_element_join_on,
Expand Down Expand Up @@ -97,6 +95,23 @@ def factory_class_name_coercer
@factory_class_name_coercer || Bulkrax::FactoryClassFinder::DefaultCoercer
end


def file_model_class
@file_model_class ||= defined?(::Hyrax) ? ::FileSet : File
end

def file_model_class=(val)
@file_model_class = val
end

def curation_concerns
@curation_concerns ||= defined?(::Hyrax) ? ::Hyrax.config.curation_concerns : []
end

def curation_concerns=(val)
@curation_concerns = val
end

attr_writer :ingest_queue_name
##
# @return [String, Proc]
Expand Down Expand Up @@ -222,22 +237,6 @@ def config
conf.relationship_job_class = "Bulkrax::CreateRelationshipsJob"
conf.required_elements = ['title']

def conf.curation_concerns
@curation_concerns ||= defined?(::Hyrax) ? ::Hyrax.config.curation_concerns : []
end

def conf.curation_concerns=(val)
@curation_concerns = val
end

def conf.file_model_class
@file_model_class ||= defined?(::Hyrax) ? ::FileSet : File
end

def conf.file_model_class=(val)
@file_model_class = val
end

# Hash of Generic field_mappings for use in the view
# There must be one field_mappings hash per view partial
# Based on Hyrax CoreMetadata && BasicMetadata
Expand Down

0 comments on commit e1c5e0d

Please sign in to comment.