samvera / active_fedora

A Rails interface to the Fedora repository, akin to ActiveModel
Other
54 stars 63 forks source link

[backport] Fix `#blank?` and `#present?` #1362

Closed no-reply closed 6 years ago

no-reply commented 6 years ago

Rails' Object#blank? and Object#present? return true for empty Enumerable objects. This is because they don't implement #empty?.

Our prior effort to optimize these methods for Relation by delegating them to #each broke them for this reason, always returning true. Instead, we delegate #any? which does exist, and implement Relation#empty? directly as its inverse. Rails provides the #blank? and #present? implementations.