Module: DataMapper::Constraints::DeleteConstraint::ClassMethods
- Included in:
- ClassMethods
- Defined in:
- lib/dm-constraints/delete_constraint.rb
Constant Summary collapse
- CONSTRAINT_OPTIONS =
[ :protect, :destroy, :destroy!, :set_nil, :skip ].to_set.freeze
Instance Method Summary collapse
-
#check_delete_constraint_type(cardinality, name, *args) ⇒ nil
Checks that the constraint type is appropriate to the relationship.
Instance Method Details
#check_delete_constraint_type(cardinality, name, *args) ⇒ nil
Checks that the constraint type is appropriate to the relationship
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/dm-constraints/delete_constraint.rb', line 25 def check_delete_constraint_type(cardinality, name, *args) = (args) return unless .key?(:constraint) constraint = [:constraint] unless CONSTRAINT_OPTIONS.include?(constraint) raise ArgumentError, ":constraint option must be one of #{CONSTRAINT_OPTIONS.to_a.join(', ')}" end # XXX: is any constraint valid with a :through relationship? if constraint == :set_nil && .key?(:through) raise ArgumentError, 'Constraint type :set_nil is not valid for relationships using :through' end end |