Skip to content

Commit

Permalink
Update proxy.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyshields authored Nov 8, 2023
1 parent 7522238 commit e6099e6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/mongoid/association/embedded/embeds_many/proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,12 @@ def destroy_all(conditions = {})
#
# @return [ true | false ] True if persisted documents exist, false if not.
def exists?(id_or_conditions = :none)
return _target.any?(&:persisted?) if id_or_conditions == :none

criteria.exists?(id_or_conditions)
case id_or_conditions
when :none then _target.any?(&:persisted?)
when nil, false then false
when Hash then where(id_or_conditions).any?(&:persisted?)
else where(_id: id_or_conditions).any?(&:persisted?)
end
end

# Finds a document in this association through several different
Expand Down

0 comments on commit e6099e6

Please sign in to comment.