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.

Methods

drop   new   operator   process  

Public Class methods

Store the schema generator that encloses this validates block.

[Source]

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

Public Instance methods

Given the name of a constraint, drop that constraint from the database, and remove the related validation metadata.

[Source]

     # File lib/sequel/extensions/constraint_validations.rb, line 197
197:       def drop(constraint)
198:         @generator.validation({:type=>:drop, :name=>constraint})
199:       end

Create operator validation. The op should be either +:>+, +:>=+, +:<+, or +:<=+, and the arg should be either a string or an integer.

[Source]

     # 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

Alias of instance_exec for a nicer API.

[Source]

     # File lib/sequel/extensions/constraint_validations.rb, line 202
202:       def process(&block)
203:         instance_exec(&block)
204:       end

[Validate]