Method: Mongoid::Criteria#merge

Defined in:
lib/mongoid/criteria.rb

#merge(other) ⇒ Object

Merges another object into this Criteria. The other object may be a Criteria or a Hash. This is used to combine multiple scopes together, where a chained scope situation may be desired.

Options:

other: The Criteria or Hash to merge with.

Example:

criteria.merge({ :conditions => { :title => "Sir" } })



151
152
153
154
155
# File 'lib/mongoid/criteria.rb', line 151

def merge(other)
  @selector.update(other.selector)
  @options.update(other.options)
  @documents = other.documents
end