module Sequel::Plugins::AutoValidations::ClassMethods

  1. lib/sequel/plugins/auto_validations.rb

Attributes

auto_validate_explicit_not_null_columns [R]

The columns with automatic not_null validations for columns present in the values.

auto_validate_max_length_columns [R]

The columns or sets of columns with automatic max_length validations, as an array of pairs, with the first entry being the column name and second entry being the maximum length.

auto_validate_not_null_columns [R]

The columns with automatic not_null validations

auto_validate_options [R]

Inherited options

auto_validate_unique_columns [R]

The columns or sets of columns with automatic unique validations

Public Instance methods

auto_validate_presence?()

Whether to use a presence validation for not null columns

[show source]
    # File lib/sequel/plugins/auto_validations.rb
142 def auto_validate_presence?
143   @auto_validate_presence
144 end
auto_validate_types?()

Whether to automatically validate schema types for all columns

[show source]
    # File lib/sequel/plugins/auto_validations.rb
147 def auto_validate_types?
148   @auto_validate_types
149 end
freeze()

Freeze auto_validation settings when freezing model class.

[show source]
    # File lib/sequel/plugins/auto_validations.rb
152 def freeze
153   @auto_validate_not_null_columns.freeze
154   @auto_validate_explicit_not_null_columns.freeze
155   @auto_validate_max_length_columns.freeze
156   @auto_validate_unique_columns.freeze
157 
158   super
159 end
skip_auto_validations(type)

Skip automatic validations for the given validation type (:not_null, :types, :unique). If :all is given as the type, skip all auto validations.

[show source]
    # File lib/sequel/plugins/auto_validations.rb
163 def skip_auto_validations(type)
164   case type
165   when :all
166     [:not_null, :types, :unique, :max_length].each{|v| skip_auto_validations(v)}
167   when :not_null
168     auto_validate_not_null_columns.clear
169     auto_validate_explicit_not_null_columns.clear
170   when :types
171     @auto_validate_types = false
172   else
173     public_send("auto_validate_#{type}_columns").clear
174   end
175 end