Skip to content

Commit

Permalink
Update to boolean parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
ebtoner committed Dec 8, 2023
1 parent 822f187 commit 33c1632
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/cob_index/macros/custom.rb
Original file line number Diff line number Diff line change
Expand Up @@ -891,16 +891,16 @@ def extract_donor
end
end

def extract_marc_subfield_limit(spec, subfield_limit, boolean)
def extract_marc_subfield_limit(spec, subfield_limit, subfield_boolean)
# spec is the standard extract_marc string.
# subfield_limit is a string of the subfield code used to limit the extracted marc output.
# boolean is either true or false.
# subfield_boolean is either true or false.
# If true, extract_marc_subfield_limit will only extract a field if that field also includes a subfield that matches the subfield_limit code.
# If false, extract_marc_subfield_limit will only extract a field from spec if it does not include a subfield that matches the subfield_limit code.

lambda do |rec, acc|
values = Traject::MarcExtractor.cached(spec).collect_matching_lines(rec) do |field, spec, extractor|
if (boolean == true && field[subfield_limit]) || (boolean == false && !field[subfield_limit])
if (subfield_boolean && field[subfield_limit]) || (!subfield_boolean && !field[subfield_limit])
results = extractor.collect_subfields(field, spec)
else
[]
Expand Down

0 comments on commit 33c1632

Please sign in to comment.