Module: Sequel::Plugins::ClassTableInheritanceConstraintValidations
- Defined in:
- lib/sequel/plugins/class_table_inheritance_constraint_validations.rb
Overview
Overview
The class_table_inheritance_constraint_validations plugin extends the constraint_validations plugin to work correctly with the class_table_inheritance plugin. It ensures that constraint_validations are loaded from all tables in the class table inheritance hierarchy, not just the base table.
Example
For example, with this hierarchy, where each model has its own table with constraint validations:
Employee
/ \
Staff Manager
|
Executive
# Loads constraint_validations from the employees table
class Employee < Sequel::Model
plugin :class_table_inheritance
plugin :constraint_validations
plugin :class_table_inheritance_constraint_validations
end
# Loads constraint_validations from managers and employees tables
class Manager < Employee
end
# Loads constraint_validations from executives, managers, and
# employees tables
class Executive < Manager
end
# Loads constraint_validations from staff and employees tables
class Staff < Employee
end
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Class Method Details
.apply(model) ⇒ Object
47 48 49 50 51 |
# File 'lib/sequel/plugins/class_table_inheritance_constraint_validations.rb', line 47 def self.apply(model) unless ConstraintValidations::InstanceMethods > model && ClassTableInheritance::InstanceMethods > model raise Error, "must load the constraint_validations and class_table_inheritance plugins into #{model} before loading class_table_inheritance_constraint_validations plugin" end end |