lib/mongoid/contextual/memory.rb
# Update all the matching documents atomically.
#
# @example Update all the matching documents.
#   context.update(name: "Smiths")
#
# @param [ Hash ] attributes The new attributes for each document.
#
# @return [ nil, false ] False if no attributes were provided.
#
# @since 3.0.0
Update all the matching documents atomically.
Update all the matching documents atomically .
def update(attributes = nil)
        return false unless attributes
        updates = {}
        each do |doc|
          @selector ||= root.atomic_selector
          doc.write_attributes(attributes)
          updates.merge!(doc.atomic_position => attributes)
        end
        collection.find(selector).update("$set" => updates)
      end
def update ( attributes = nil ) return false unless attributes updates = { } each do | doc | @selector ||= root . atomic_selector doc . write_attributes ( attributes ) updates . merge! ( doc . atomic_position => attributes ) end collection . find ( selector ) . update ( "$set" => updates ) end
Update all the matching documents atomically.
Update all the matching documents atomically .
False if no attributes were provided.
False if no attributes were provided .
 nil, false 
attributes
<not_specific>
<not_specific>
attributes The new attributes for each document.
attributes The new attributes for each document .
example
Update all the matching documents. context.update(name: "Smiths")
Update all the matching documents . context . update ( name : " Smiths " )
since
None