Sha256: ab66ee76bb68366d9c3367eed9fa4e6fa037e3da3d89f544a29342e3af74cbcf
Contents?: true
Size: 1.03 KB
Versions: 9
Compression:
Stored size: 1.03 KB
Contents
# encoding: utf-8 module Mongoid # :nodoc: module Relations #:nodoc: # This module contains the behaviour for auto-saving relations in # different collections. module AutoSave extend ActiveSupport::Concern module ClassMethods #:nodoc: # Set up the autosave behaviour for references many and references one # relations. When the option is set to true, these relations will get # saved automatically when the parent is first saved, but not if the # parent already exists in the database. # # @example Set up autosave options. # Person.autosave(metadata) # # @param [ Metadata ] metadata The relation metadata. # # @since 2.0.0.rc.1 def autosave(metadata) if metadata.autosave? set_callback :save, :after do |document| relation = document.send(metadata.name) relation.in_memory.each { |doc| doc.save } if relation end end end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems