module Sequel::Plugins::ClassTableInheritanceConstraintValidations

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