Sha256: 1e149ddcf01b2c634325423ab62cb1df6616453524069e77c7f0dc71fa46963e
Contents?: true
Size: 1018 Bytes
Versions: 91
Compression:
Stored size: 1018 Bytes
Contents
# encoding: utf-8 module Mongoid module Relations module Cascading class Nullify attr_accessor :document, :relation, :metadata # Initialize the new cascade strategy, which will set up the relation # and the metadata. # # @example Instantiate the strategy # Strategy.new(document, metadata) # # @param [ Document ] document The document to cascade from. # @param [ Metadata ] metadata The relation's metadata. # # @return [ Strategy ] The new strategy. def initialize(document, metadata) @document, @metadata = document, metadata @relation = document.send(metadata.name) end # This cascade does not delete the referenced relations, but instead # sets the foreign key values to nil. # # @example Nullify the reference. # strategy.cascade def cascade relation.nullify if relation end end end end end
Version data entries
91 entries across 86 versions & 7 rubygems