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.
Coverage increased (+0.02%) to 89.59% when pulling 34ba358d993d4a9debcfbea6b0bc3617b3d46b7a on fix-blank-present into 0e2356dd19e012f642b70e5f55d418cda0748f64 on master.
Rails'
Object#blank?
andObject#present?
returntrue
for emptyEnumerable
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 returningtrue
. Instead, we delegate#any?
which does exist, and implementRelation#empty?
directly as its inverse. Rails provides the#blank?
and#present?
implementations.