8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/mm_partial_update/embedded_collection.rb', line 8
def add_updates_to_command(changes, command)
selector = association.name
selector = "#{proxy_owner.database_selector}.#{selector}" if
proxy_owner.respond_to?(:database_selector)
unless changes.blank?
deleted = changes[0] - changes[1]
deleted.each { |d| command.pull(selector, d._id) }
end
unless @target.blank?
@target.each do |child|
child.new? ? command.push(selector, child.to_mongo) :
child.add_updates_to_command(command)
end
end
end
|