DataMapper::Constraints::Resource

Public Instance Methods

before_destroy_hook() click to toggle source
   # File lib/data_mapper/constraints/resource.rb, line 4
4:       def before_destroy_hook
5:         enforce_destroy_constraints
6:         super
7:       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
20:       def enforce_destroy_constraints
21:         relationships.each do |relationship|
22:           next unless relationship.respond_to?(:enforce_destroy_constraint)
23: 
24:           constraint_satisfied = relationship.enforce_destroy_constraint(self)
25: 
26:           throw(:halt, false) unless constraint_satisfied
27:         end
28:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.