Skip to content

Instantly share code, notes, and snippets.

@mbklein
Created January 18, 2019 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbklein/994d2989932d59dbe2edd01f56e49f76 to your computer and use it in GitHub Desktop.
Save mbklein/994d2989932d59dbe2edd01f56e49f76 to your computer and use it in GitHub Desktop.
Batch Item Check
def check
return false if work.nil?
attached_titles = work.ordered_members.to_a.collect { |fs| fs.title.first }
expected_titles = attribute_hash[:file].collect { |fn| File.basename(fn) }
extra_titles = attached_titles - expected_titles
missing_titles = expected_titles - attached_titles
return true if extra_titles.empty? && missing_titles.empty?
yield(work: work, missing: missing_titles, extra: extra_titles)
false
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment