Skip to content

Commit

Permalink
🐛 Fix multivalue split and join on configs
Browse files Browse the repository at this point in the history
This commit will move the :multi_value_element_join_on and
:multi_value_element_split_on config options into the `Configuration`
class.  Previous, the Bulkrax initializer was not able to set these
options.
  • Loading branch information
kirkkwang committed Jan 7, 2025
1 parent a716035 commit 57bc4aa
Showing 1 changed file with 27 additions and 25 deletions.
52 changes: 27 additions & 25 deletions lib/bulkrax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ class Configuration
:field_mappings,
:generated_metadata_mapping,
:import_path,
:multi_value_element_join_on,
:multi_value_element_split_on,
:object_factory,
:parsers,
:qa_controlled_properties,
Expand Down Expand Up @@ -175,6 +173,33 @@ def use_locking
ENV.key?("REDIS_HOST")
end
alias use_locking? use_locking

DEFAULT_MULTI_VALUE_ELEMENT_JOIN_ON = ' | '
# Specify the delimiter for joining an attribute's multi-value array into a string.
#
# @note the specific delimiter should likely be present in the multi_value_element_split_on
# expression.
def multi_value_element_join_on
@multi_value_element_join_on ||= DEFAULT_MULTI_VALUE_ELEMENT_JOIN_ON
end

attr_writer :multi_value_element_split_on

DEFAULT_MULTI_VALUE_ELEMENT_SPLIT_ON = /\s*[:;|]\s*/.freeze
# @return [RegexClass] the regular express to use to "split" an attribute's values. If set to
# `true` use the DEFAULT_MULTI_VALUE_ELEMENT_JOIN_ON.
#
# @note The "true" value is to preserve backwards compatibility.
# @see DEFAULT_MULTI_VALUE_ELEMENT_JOIN_ON
def multi_value_element_split_on
if @multi_value_element_split_on.is_a?(TrueClass)
DEFAULT_MULTI_VALUE_ELEMENT_SPLIT_ON
else
@multi_value_element_split_on ||= DEFAULT_MULTI_VALUE_ELEMENT_SPLIT_ON
end
end

attr_writer :multi_value_element_join_on
end

def config
Expand Down Expand Up @@ -361,29 +386,6 @@ def api_definition
)
end

DEFAULT_MULTI_VALUE_ELEMENT_JOIN_ON = ' | '
# Specify the delimiter for joining an attribute's multi-value array into a string.
#
# @note the specific delimiter should likely be present in the multi_value_element_split_on
# expression.
def multi_value_element_join_on
@multi_value_element_join_on ||= DEFAULT_MULTI_VALUE_ELEMENT_JOIN_ON
end

DEFAULT_MULTI_VALUE_ELEMENT_SPLIT_ON = /\s*[:;|]\s*/.freeze
# @return [RegexClass] the regular express to use to "split" an attribute's values. If set to
# `true` use the DEFAULT_MULTI_VALUE_ELEMENT_JOIN_ON.
#
# @note The "true" value is to preserve backwards compatibility.
# @see DEFAULT_MULTI_VALUE_ELEMENT_JOIN_ON
def multi_value_element_split_on
if @multi_value_element_join_on.is_a?(TrueClass)
DEFAULT_MULTI_VALUE_ELEMENT_SPLIT_ON
else
@multi_value_element_split_on ||= DEFAULT_MULTI_VALUE_ELEMENT_SPLIT_ON
end
end

# Responsible for stripping hidden characters from the given string.
#
# @param value [#to_s]
Expand Down

0 comments on commit 57bc4aa

Please sign in to comment.