module Sequel::Plugins::PgAutoConstraintValidations::ClassMethods

  1. lib/sequel/plugins/pg_auto_constraint_validations.rb

Attributes

pg_auto_constraint_validations [R]

Hash of metadata checked when an instance attempts to convert a constraint violation into a validation failure.

pg_auto_constraint_validations_messages [R]

Hash of error messages keyed by constraint type symbol to use in the generated validation failures.

Public Instance methods

dump_pg_auto_constraint_validations_cache()

Dump the in-memory cached metadata to the cache file.

[show source]
    # File lib/sequel/plugins/pg_auto_constraint_validations.rb
132 def dump_pg_auto_constraint_validations_cache
133   raise Error, "No pg_auto_constraint_validations setup" unless file = @pg_auto_constraint_validations_cache_file
134   File.open(file, 'wb'){|f| f.write(Marshal.dump(@pg_auto_constraint_validations_cache))}
135   nil
136 end
pg_auto_constraint_validation_override(constraint, columns, message)

Override the constraint validation columns and message for a given constraint

[show source]
    # File lib/sequel/plugins/pg_auto_constraint_validations.rb
139 def pg_auto_constraint_validation_override(constraint, columns, message)
140   pgacv = Hash[@pg_auto_constraint_validations]
141   overrides = pgacv[:overrides] = Hash[pgacv[:overrides]]
142   overrides[constraint] = [Array(columns), message].freeze
143   overrides.freeze
144   @pg_auto_constraint_validations = pgacv.freeze
145   nil
146 end