Skip to content

Support multiple analyzers during `ActiveStorage::Blob#analyze`

Created by: seanpdoyle

Motivation / Background

Prior to this commit, Blob analysis could only involve a single Analyzer. By default, the metadata typically includes information about dimensions (for image and video).

If applications need to include more involved analysis, they also have to re-implement the dimension analysis on their own (either through composition, inheritance, or copy-pasting).

Detail

This commit extends analysis to support multiple anaylzer classes by replacing Enumerable#detect with Enumerable#select, and a Hash#merge with an Enumerable#reduce.

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

Merge request reports