Sha256: 3ab91652fbe63a7f77051048e4b89b9deaccd1b047b28117d8a906dcfad7b386
Contents?: true
Size: 1.07 KB
Versions: 21
Compression:
Stored size: 1.07 KB
Contents
# encoding: UTF-8 module MongoMapper module Plugins module Associations class OneAssociation < SingleAssociation def embeddable? klass.embeddable? end def proxy_class @proxy_class ||= if klass.embeddable? polymorphic? ? OneEmbeddedPolymorphicProxy : OneEmbeddedProxy elsif as? OneAsProxy else OneProxy end end def setup(model) super association = self options = self.options model.before_destroy do if !association.embeddable? proxy = self.get_proxy(association) unless proxy.nil? case options[:dependent] when :destroy then proxy.destroy when :delete then proxy.delete else proxy.nullify end end end end end def autosave? options.fetch(:autosave, embeddable?) end end end end end
Version data entries
21 entries across 21 versions & 3 rubygems