class Sequel::ConstraintValidations::Generator

This is the DSL class used for the validate block inside create_table and alter_table.

Public Class Methods

new(generator) click to toggle source

Store the schema generator that encloses this validates block.

    # File lib/sequel/extensions/constraint_validations.rb
154 def initialize(generator)
155   @generator = generator
156 end

Public Instance Methods

drop(constraint) click to toggle source

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
195 def drop(constraint)
196   @generator.validation({:type=>:drop, :name=>constraint})
197 end
operator(op, arg, columns, opts=OPTS) click to toggle source

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
178 def operator(op, arg, columns, opts=OPTS)
179   raise Error, "invalid operator (#{op}) used when creating operator validation" unless suffix = OPERATORS[op]
180 
181   prefix = case arg
182   when String
183     "str"
184   when Integer
185     "int"
186   else
187     raise Error, "invalid argument (#{arg.inspect}) used when creating operator validation"
188   end
189 
190   @generator.validation({:type=>:"#{prefix}_#{suffix}", :columns=>Array(columns), :arg=>arg}.merge!(opts))
191 end
process(&block) click to toggle source

Alias of instance_exec for a nicer API.

    # File lib/sequel/extensions/constraint_validations.rb
200 def process(&block)
201   instance_exec(&block)
202 end