Module: Sequel::Plugins::AutoValidations::ClassMethods
- Defined in:
- lib/sequel/plugins/auto_validations.rb
Instance Attribute Summary collapse
-
#auto_validate_explicit_not_null_columns ⇒ Object
readonly
The columns with automatic not_null validations for columns present in the values.
-
#auto_validate_max_length_columns ⇒ Object
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.
-
#auto_validate_not_null_columns ⇒ Object
readonly
The columns with automatic not_null validations.
-
#auto_validate_options ⇒ Object
readonly
Inherited options.
-
#auto_validate_unique_columns ⇒ Object
readonly
The columns or sets of columns with automatic unique validations.
Instance Method Summary collapse
-
#auto_validate_presence? ⇒ Boolean
Whether to use a presence validation for not null columns.
-
#auto_validate_types? ⇒ Boolean
Whether to automatically validate schema types for all columns.
-
#freeze ⇒ Object
Freeze auto_validation settings when freezing model class.
-
#skip_auto_validations(type) ⇒ Object
Skip automatic validations for the given validation type (:not_null, :types, :unique).
Instance Attribute Details
#auto_validate_explicit_not_null_columns ⇒ Object (readonly)
The columns with automatic not_null validations for columns present in the values.
112 113 114 |
# File 'lib/sequel/plugins/auto_validations.rb', line 112 def auto_validate_explicit_not_null_columns @auto_validate_explicit_not_null_columns end |
#auto_validate_max_length_columns ⇒ Object (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.
116 117 118 |
# File 'lib/sequel/plugins/auto_validations.rb', line 116 def auto_validate_max_length_columns @auto_validate_max_length_columns end |
#auto_validate_not_null_columns ⇒ Object (readonly)
The columns with automatic not_null validations
109 110 111 |
# File 'lib/sequel/plugins/auto_validations.rb', line 109 def auto_validate_not_null_columns @auto_validate_not_null_columns end |
#auto_validate_options ⇒ Object (readonly)
Inherited options
122 123 124 |
# File 'lib/sequel/plugins/auto_validations.rb', line 122 def @auto_validate_options end |
#auto_validate_unique_columns ⇒ Object (readonly)
The columns or sets of columns with automatic unique validations
119 120 121 |
# File 'lib/sequel/plugins/auto_validations.rb', line 119 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
128 129 130 |
# File 'lib/sequel/plugins/auto_validations.rb', line 128 def auto_validate_presence? @auto_validate_presence end |
#auto_validate_types? ⇒ Boolean
Whether to automatically validate schema types for all columns
133 134 135 |
# File 'lib/sequel/plugins/auto_validations.rb', line 133 def auto_validate_types? @auto_validate_types end |
#freeze ⇒ Object
Freeze auto_validation settings when freezing model class.
138 139 140 141 142 143 144 145 |
# File 'lib/sequel/plugins/auto_validations.rb', line 138 def freeze @auto_validate_not_null_columns.freeze @auto_validate_explicit_not_null_columns.freeze @auto_validate_max_length_columns.freeze @auto_validate_unique_columns.freeze super 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.
149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/sequel/plugins/auto_validations.rb', line 149 def skip_auto_validations(type) case type when :all [:not_null, :types, :unique, :max_length].each{|v| skip_auto_validations(v)} when :not_null auto_validate_not_null_columns.clear auto_validate_explicit_not_null_columns.clear when :types @auto_validate_types = false else public_send("auto_validate_#{type}_columns").clear end end |