Module: DataMapper::Constraints
- Includes:
- DeleteConstraint
- Defined in:
- lib/dm-constraints.rb,
lib/dm-constraints/migrations.rb,
lib/dm-constraints/delete_constraint.rb,
lib/dm-constraints/adapters/dm-do-adapter.rb,
lib/dm-constraints/adapters/dm-mysql-adapter.rb,
lib/dm-constraints/adapters/dm-oracle-adapter.rb,
lib/dm-constraints/adapters/dm-sqlite-adapter.rb,
lib/dm-constraints/adapters/dm-abstract-adapter.rb,
lib/dm-constraints/adapters/dm-postgres-adapter.rb,
lib/dm-constraints/adapters/dm-sqlserver-adapter.rb
Defined Under Namespace
Modules: Adapters, ClassMethods, DeleteConstraint, Migrations
Class Method Summary collapse
- .include_constraint_api ⇒ Object
-
.included(model) ⇒ Object
Add before hooks to #has to check for proper constraint definitions Add before hooks to #destroy to properly constrain children.
Methods included from DeleteConstraint
Class Method Details
.include_constraint_api ⇒ Object
40 41 42 43 44 |
# File 'lib/dm-constraints.rb', line 40 def self.include_constraint_api DataMapper::Adapters::AbstractAdapter.descendants.each do |adapter_class| DataMapper::Adapters.include_constraint_api(DataMapper::Inflector.demodulize(adapter_class.name)) end end |
.included(model) ⇒ Object
Add before hooks to #has to check for proper constraint definitions Add before hooks to #destroy to properly constrain children
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/dm-constraints.rb', line 29 def self.included(model) model.extend(ClassMethods) model.class_eval <<-RUBY, __FILE__, __LINE__ + 1 before_class_method :has, :check_delete_constraint_type if instance_methods.any? { |m| m.to_sym == :destroy } before :destroy, :check_delete_constraints end RUBY end |