Method: Mongoid::Criterion::Inclusion#or
- Defined in:
- lib/mongoid/criterion/inclusion.rb
#or ⇒ Criteria
Adds a criterion to the Criteria
that specifies a set of expressions to match if any of them return true. This is a $or query in MongoDB and is similar to a SQL OR. This is named #any_of and aliased “or” for readability.
97 98 99 100 101 102 103 104 |
# File 'lib/mongoid/criterion/inclusion.rb', line 97 def any_of(*args) clone.tap do |crit| criterion = @selector["$or"] || [] converted = BSON::ObjectId.convert(klass, args.flatten) = converted.collect { |hash| hash. } crit.selector["$or"] = criterion.concat() end end |