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
134 def dump_pg_auto_constraint_validations_cache
135   raise Error, "No pg_auto_constraint_validations setup" unless file = @pg_auto_constraint_validations_cache_file
136   pg_auto_constraint_validations_cache = {}
137   @pg_auto_constraint_validations_cache.sort.each do |k, v|
138     pg_auto_constraint_validations_cache[k] = v
139   end
140   File.open(file, 'wb'){|f| f.write(Marshal.dump(pg_auto_constraint_validations_cache))}
141   nil
142 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
145 def pg_auto_constraint_validation_override(constraint, columns, message)
146   pgacv = Hash[@pg_auto_constraint_validations]
147   overrides = pgacv[:overrides] = Hash[pgacv[:overrides]]
148   overrides[constraint] = [Array(columns), message].freeze
149   overrides.freeze
150   @pg_auto_constraint_validations = pgacv.freeze
151   nil
152 end