lib/mongoid/criteria/queryable/selector.rb
# Merges another selector into this one.
#
# @example Merge in another selector.
#   selector.merge!(name: "test")
#
# @param [ Hash, Selector ] other The object to merge in.
#
# @return [ Selector ] The selector.
Merges another selector into this one.
Merges another selector into this one .
def merge!(other)
          other.each_pair do |key, value|
            if value.is_a?(Hash) && self[key.to_s].is_a?(Hash)
              value = self[key.to_s].merge(value) do |_key, old_val, new_val|
                case _key
                when '$in'
                  new_val & old_val
                when '$nin'
                  (old_val + new_val).uniq
                else
                  new_val
                end
              end
            end
            if multi_selection?(key)
              value = (self[key.to_s] || []).concat(value)
            end
            store(key, value)
          end
        end
def merge! ( other ) other . each_pair do | key , value | if value . is_a? ( Hash ) && self [ key . to_s ] . is_a? ( Hash ) value = self [ key . to_s ] . merge ( value ) do | _key , old_val , new_val | case _key when '$in' new_val & old_val when '$nin' ( old_val + new_val ) . uniq else new_val end end end if multi_selection? ( key ) value = ( self [ key . to_s ] || [ ] ) . concat ( value ) end store ( key , value ) end end
Merges another selector into this one.
Merges another selector into this one .
None
 Selector 
other
<not_specific>
<not_specific>
other The object to merge in.
other The object to merge in .
example
Merge in another selector. selector.merge!(name: "test")
Merge in another selector . selector . merge! ( name : " test " )