Class | Sequel::ConstraintValidations::Generator |
In: |
lib/sequel/extensions/constraint_validations.rb
|
Parent: | Object |
This is the DSL class used for the validate block inside create_table and alter_table.
Store the schema generator that encloses this validates block.
# File lib/sequel/extensions/constraint_validations.rb, line 154 154: def initialize(generator) 155: @generator = generator 156: end
Create operator validation. The op should be either +:>+, +:>=+, +:<+, or +:<=+, and the arg should be either a string or an integer.
# File lib/sequel/extensions/constraint_validations.rb, line 180 180: def operator(op, arg, columns, opts=OPTS) 181: raise Error, "invalid operator (#{op}) used when creating operator validation" unless suffix = OPERATORS[op] 182: 183: prefix = case arg 184: when String 185: "str" 186: when Integer 187: "int" 188: else 189: raise Error, "invalid argument (#{arg.inspect}) used when creating operator validation" 190: end 191: 192: @generator.validation({:type=>"#{prefix}_#{suffix}""#{prefix}_#{suffix}", :columns=>Array(columns), :arg=>arg}.merge!(opts)) 193: end