Module: Sequel::Plugins::ConstraintValidations::ClassMethods

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#constraint_validation_reflectionsObject (readonly)

A hash of reflections of constraint validations. Keys are type name symbols. Each value is an array of pairs, with the first element being the validation type symbol (e.g. :presence) and the second element being options for the validation. If the validation takes an argument, it appears as the :argument entry in the validation option hash.



85
86
87
# File 'lib/sequel/plugins/constraint_validations.rb', line 85

def constraint_validation_reflections
  @constraint_validation_reflections
end

#constraint_validationsObject (readonly)

An array of validation method call arrays. Each array is an array that is splatted to send to perform a validation via validation_helpers.



78
79
80
# File 'lib/sequel/plugins/constraint_validations.rb', line 78

def constraint_validations
  @constraint_validations
end

#constraint_validations_tableObject (readonly)

The name of the table containing the constraint validations metadata.



88
89
90
# File 'lib/sequel/plugins/constraint_validations.rb', line 88

def constraint_validations_table
  @constraint_validations_table
end

Instance Method Details

#freezeObject

Freeze constraint validations data when freezing model class.



94
95
96
97
98
99
100
101
102
103
# File 'lib/sequel/plugins/constraint_validations.rb', line 94

def freeze
  @constraint_validations.freeze.each(&:freeze)
  @constraint_validation_reflections.freeze.each_value do |v|
    v.freeze
    v.each(&:freeze)
  end
  @constraint_validation_options.freeze.each_value(&:freeze)

  super
end