Module: DataMapper::Constraints::Relationship::OneToMany
- Defined in:
- lib/data_mapper/constraints/relationship/one_to_many.rb
Instance Attribute Summary collapse
-
#constraint ⇒ Object
readonly
Returns the value of attribute constraint.
Instance Method Summary collapse
Instance Attribute Details
#constraint ⇒ Object (readonly)
Returns the value of attribute constraint.
6 7 8 |
# File 'lib/data_mapper/constraints/relationship/one_to_many.rb', line 6 def constraint @constraint end |
Instance Method Details
#enforce_destroy_constraint(resource) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/data_mapper/constraints/relationship/one_to_many.rb', line 9 def enforce_destroy_constraint(resource) return true unless association = get(resource) constraint = self.constraint case constraint when :protect Array(association).empty? when :destroy, :destroy! association.__send__(constraint) when :set_nil Array(association).all? do |resource| resource.update(inverse => nil) end when :skip true # do nothing end end |