Sha256: a738836bba780bcde84905b2ea85fb3772598f673a62e61febe5ae1f37c5753a
Contents?: true
Size: 1.07 KB
Versions: 6
Compression:
Stored size: 1.07 KB
Contents
# encoding: UTF-8 module MarkMapper 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
6 entries across 6 versions & 1 rubygems