Ensure Item#contributors always returns an Array. Safe navigator for Item#contributors_of compact - although not really neccessary now.

This commit is contained in:
Dan Milne
2019-10-24 14:27:08 +11:00
parent d3bad8fc02
commit 1ad818b4d7

View File

@@ -51,18 +51,14 @@ module Paapi
end end
def contributors def contributors
get(%w{ItemInfo ByLineInfo Contributors}) Array(get(%w{ItemInfo ByLineInfo Contributors}))
end end
def contributors_of(kind) def contributors_of(kind)
contributors&.select { |e| e['Role'] == kind.to_s.gsub(/([[:alpha:]]+)/) { |w| w.capitalize } }&.map do |e| contributors&.select { |e| e['Role'] == kind.to_s.gsub(/([[:alpha:]]+)/).each { |w| w.capitalize } }&.map do |e|
r = e['Name'] r = e['Name']
Nameable(r) unless r.to_s.empty? Nameable(r) unless r.to_s.empty?
end.compact end&.compact
end
def contributors_of1(kind)
contributors&.select { |e| e['Role'] == kind.to_s.gsub(/([[:alpha:]]+)/) { |w| w.capitalize } }&.map { |e| Nameable(e['Name'])}
end end
def actors def actors