Guest User

Untitled

a guest
Jul 18th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. # encoding: utf-8
  2. module Mongoid #:nodoc:
  3. module Associations #:nodoc:
  4. module EmbeddedCallbacks
  5.  
  6. # bubble callbacks to embedded associations
  7. def run_callbacks(kind, *args, &block)
  8. # now bubble callbacks down
  9. self.associations.each_pair do |name, meta|
  10. if meta.association == Mongoid::Associations::EmbedsMany
  11. self.send(name).each { |doc| doc.send(:run_callbacks, kind, *args, &block) }
  12. elsif meta.association == Mongoid::Associations::EmbedsOne
  13. self.send(name).send(:run_callbacks, kind, *args, &block)
  14. end
  15. end
  16. super(kind, *args, &block) # defer to parent
  17. end
  18.  
  19. end
  20. end
  21. end
Add Comment
Please, Sign In to add comment