Module: Sequel::Plugins::PgAutoConstraintValidations::ClassMethods

Defined in:
lib/sequel/plugins/pg_auto_constraint_validations.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pg_auto_constraint_validationsObject (readonly)

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



82
83
84
# File 'lib/sequel/plugins/pg_auto_constraint_validations.rb', line 82

def pg_auto_constraint_validations
  @pg_auto_constraint_validations
end

#pg_auto_constraint_validations_messagesObject (readonly)

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



86
87
88
# File 'lib/sequel/plugins/pg_auto_constraint_validations.rb', line 86

def pg_auto_constraint_validations_messages
  @pg_auto_constraint_validations_messages
end

Instance Method Details

#pg_auto_constraint_validation_override(constraint, columns, message) ⇒ Object

Override the constraint validation columns and message for a given constraint



92
93
94
95
96
97
98
99
# File 'lib/sequel/plugins/pg_auto_constraint_validations.rb', line 92

def pg_auto_constraint_validation_override(constraint, columns, message)
  pgacv = Hash[@pg_auto_constraint_validations]
  overrides = pgacv[:overrides] = Hash[pgacv[:overrides]]
  overrides[constraint] = [Array(columns), message].freeze
  overrides.freeze
  @pg_auto_constraint_validations = pgacv.freeze
  nil
end