Module: Sequel::Plugins::AutoValidations::ClassMethods

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#auto_validate_explicit_not_null_columnsObject (readonly)

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



103
104
105
# File 'lib/sequel/plugins/auto_validations.rb', line 103

def auto_validate_explicit_not_null_columns
  @auto_validate_explicit_not_null_columns
end

#auto_validate_max_length_columnsObject (readonly)

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.



107
108
109
# File 'lib/sequel/plugins/auto_validations.rb', line 107

def auto_validate_max_length_columns
  @auto_validate_max_length_columns
end

#auto_validate_not_null_columnsObject (readonly)

The columns with automatic not_null validations



100
101
102
# File 'lib/sequel/plugins/auto_validations.rb', line 100

def auto_validate_not_null_columns
  @auto_validate_not_null_columns
end

#auto_validate_optionsObject (readonly)

Inherited options



113
114
115
# File 'lib/sequel/plugins/auto_validations.rb', line 113

def auto_validate_options
  @auto_validate_options
end

#auto_validate_unique_columnsObject (readonly)

The columns or sets of columns with automatic unique validations



110
111
112
# File 'lib/sequel/plugins/auto_validations.rb', line 110

def auto_validate_unique_columns
  @auto_validate_unique_columns
end

Instance Method Details

#auto_validate_presence?Boolean

Whether to use a presence validation for not null columns

Returns:

  • (Boolean)


119
120
121
# File 'lib/sequel/plugins/auto_validations.rb', line 119

def auto_validate_presence?
  @auto_validate_presence
end

#auto_validate_types?Boolean

Whether to automatically validate schema types for all columns

Returns:

  • (Boolean)


124
125
126
# File 'lib/sequel/plugins/auto_validations.rb', line 124

def auto_validate_types?
  @auto_validate_types
end

#skip_auto_validations(type) ⇒ Object

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



130
131
132
133
134
135
136
137
138
# File 'lib/sequel/plugins/auto_validations.rb', line 130

def skip_auto_validations(type)
  if type == :all
    [:not_null, :types, :unique, :max_length].each{|v| skip_auto_validations(v)}
  elsif type == :types
    @auto_validate_types = false
  else
    send("auto_validate_#{type}_columns").clear
  end
end