module DataMapper::Constraints::Resource
Public Instance Methods
before_destroy_hook()
click to toggle source
Calls superclass method
# File lib/data_mapper/constraints/resource.rb, line 4 def before_destroy_hook enforce_destroy_constraints super end
Private Instance Methods
enforce_destroy_constraints()
click to toggle source
Check delete constraints prior to destroying a dm resource or collection
@note
- It only considers a relationship's constraints if this is the parent model (ie a child shouldn't delete a parent) - Many to Many Relationships are skipped, as they are evaluated by their underlying 1:M relationships
@return [nil]
@api semi-public
# File lib/data_mapper/constraints/resource.rb, line 20 def enforce_destroy_constraints relationships.each do |relationship| next unless relationship.respond_to?(:enforce_destroy_constraint) constraint_satisfied = relationship.enforce_destroy_constraint(self) throw(:halt, false) unless constraint_satisfied end end