Module: MongoMapper::Plugins::EmbeddedCallbacks
- Extended by:
- ActiveSupport::Concern
- Included in:
- Document, EmbeddedDocument
- Defined in:
- lib/mongo_mapper/plugins/embedded_callbacks.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
Instance Method Details
#run_callbacks(callback, *args, &block) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/mongo_mapper/plugins/embedded_callbacks.rb', line 34 def run_callbacks(callback, *args, &block) if self.class. = [] .each do |association| += Array(get_proxy(association).send(:load_target)) end block = .inject(block) do |chain, doc| if doc.class.respond_to?("_#{callback}_callbacks") lambda { doc.run_callbacks(callback, *args, &chain) } else chain end end end super callback, *args, &block end |