lib/mongo_mapper/plugins/callbacks.rb in mongo_mapper-0.7.3 vs lib/mongo_mapper/plugins/callbacks.rb in mongo_mapper-0.7.4
- old
+ new
@@ -79,12 +79,16 @@
def run_callbacks(kind, options = {}, &block)
callback_chain_method = "#{kind}_callback_chain"
return unless self.class.respond_to?(callback_chain_method)
self.class.send(callback_chain_method).run(self, options, &block)
self.embedded_associations.each do |association|
- self.send(association.name).each do |document|
- document.run_callbacks(kind, options, &block)
+ if association.one?
+ self.send(association.name).run_callbacks(kind, options, &block)
+ else
+ self.send(association.name).each do |document|
+ document.run_callbacks(kind, options, &block)
+ end
end
end
end
private
@@ -231,6 +235,6 @@
![options[:unless]].flatten.compact.any? { |a| evaluate_method(a, *args) }
end
end
end
end
-end
\ No newline at end of file
+end