class Mongoid::Relations::Cascading::Nullify
Attributes
document[RW]
metadata[RW]
relation[RW]
Public Class Methods
new(document, metadata)
click to toggle source
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.
# File lib/mongoid/relations/cascading/nullify.rb, line 19 def initialize(document, metadata) @document, @metadata = document, metadata @relation = document.send(metadata.name) end
Public Instance Methods
cascade()
click to toggle source
This cascade does not delete the referenced relations, but instead sets the foreign key values to nil.
@example Nullify
the reference.
strategy.cascade
# File lib/mongoid/relations/cascading/nullify.rb, line 29 def cascade relation.nullify if relation end