lib/mongoid/relations/cascading/destroy.rb in mongoid-2.4.0 vs lib/mongoid/relations/cascading/destroy.rb in mongoid-2.4.1
- old
+ new
@@ -1,9 +1,26 @@
# encoding: utf-8
module Mongoid # :nodoc:
module Relations #:nodoc:
module Cascading #:nodoc:
- class Destroy < Strategy
+ class Destroy
+
+ 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
# Execute the cascading deletion for the relation if it already exists.
# This should be optimized in the future potentially not to load all
# objects from the db.
#