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 def initialize(generator) @generator = generator end
Given the name of a constraint, drop that constraint from the database, and remove the related validation metadata.
# File lib/sequel/extensions/constraint_validations.rb, line 195 def drop(constraint) @generator.validation({:type=>:drop, :name=>constraint}) 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 178 def operator(op, arg, columns, opts=OPTS) raise Error, "invalid operator (#{op}) used when creating operator validation" unless suffix = OPERATORS[op] prefix = case arg when String "str" when Integer "int" else raise Error, "invalid argument (#{arg.inspect}) used when creating operator validation" end @generator.validation({:type=>:"#{prefix}_#{suffix}", :columns=>Array(columns), :arg=>arg}.merge!(opts)) end
Alias of instance_exec for a nicer API.
# File lib/sequel/extensions/constraint_validations.rb, line 200 def process(&block) instance_exec(&block) end