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
Classes and Modules
Public Class methods
apply(model)
[show source]
# File lib/sequel/plugins/class_table_inheritance_constraint_validations.rb 47 def self.apply(model) 48 unless ConstraintValidations::InstanceMethods > model && ClassTableInheritance::InstanceMethods > model 49 raise Error, "must load the constraint_validations and class_table_inheritance plugins into #{model} before loading class_table_inheritance_constraint_validations plugin" 50 end 51 end