Module: Sequel::Plugins::PgAutoConstraintValidations::ClassMethods
- Defined in:
- lib/sequel/plugins/pg_auto_constraint_validations.rb
Instance Attribute Summary collapse
-
#pg_auto_constraint_validations ⇒ Object
readonly
Hash of metadata checked when an instance attempts to convert a constraint violation into a validation failure.
-
#pg_auto_constraint_validations_messages ⇒ Object
readonly
Hash of error messages keyed by constraint type symbol to use in the generated validation failures.
Instance Method Summary collapse
-
#dump_pg_auto_constraint_validations_cache ⇒ Object
Dump the in-memory cached metadata to the cache file.
-
#pg_auto_constraint_validation_override(constraint, columns, message) ⇒ Object
Override the constraint validation columns and message for a given constraint.
Instance Attribute Details
#pg_auto_constraint_validations ⇒ Object (readonly)
Hash of metadata checked when an instance attempts to convert a constraint violation into a validation failure.
122 123 124 |
# File 'lib/sequel/plugins/pg_auto_constraint_validations.rb', line 122 def pg_auto_constraint_validations @pg_auto_constraint_validations end |
#pg_auto_constraint_validations_messages ⇒ Object (readonly)
Hash of error messages keyed by constraint type symbol to use in the generated validation failures.
126 127 128 |
# File 'lib/sequel/plugins/pg_auto_constraint_validations.rb', line 126 def @pg_auto_constraint_validations_messages end |
Instance Method Details
#dump_pg_auto_constraint_validations_cache ⇒ Object
Dump the in-memory cached metadata to the cache file.
132 133 134 135 136 |
# File 'lib/sequel/plugins/pg_auto_constraint_validations.rb', line 132 def dump_pg_auto_constraint_validations_cache raise Error, "No pg_auto_constraint_validations setup" unless file = @pg_auto_constraint_validations_cache_file File.open(file, 'wb'){|f| f.write(Marshal.dump(@pg_auto_constraint_validations_cache))} nil end |
#pg_auto_constraint_validation_override(constraint, columns, message) ⇒ Object
Override the constraint validation columns and message for a given constraint
139 140 141 142 143 144 145 146 |
# File 'lib/sequel/plugins/pg_auto_constraint_validations.rb', line 139 def pg_auto_constraint_validation_override(constraint, columns, ) pgacv = Hash[@pg_auto_constraint_validations] overrides = pgacv[:overrides] = Hash[pgacv[:overrides]] overrides[constraint] = [Array(columns), ].freeze overrides.freeze @pg_auto_constraint_validations = pgacv.freeze nil end |