Class | Versionomy::Schema::FieldBuilder |
In: |
lib/versionomy/schema/field.rb
|
Parent: | Object |
These methods are available in a schema field definition block.
Add a child field.
Recognized options include:
:only: | The child should be available only for the given values of this field. See below for ways to specify this constraint. |
:type: | Type of field. This should be :integer, :string, or :symbol. Default is :integer. |
:default_value: | Default value for the field if no value is explicitly set. Default is 0 for an integer field, the empty string for a string field, or the first symbol added for a symbol field. |
You may provide an optional block. Within the block, you may call methods of this class again to customize the child.
Raises Versionomy::Errors::IllegalValueError if the given default value is not legal.
The :only constraint may be specified in one of the following ways:
Raises Versionomy::Errors::RangeSpecificationError if the given ranges are not legal.
Raises Versionomy::Errors::RangeOverlapError if the given ranges overlap previously specified ranges, or more than one default schema is specified.
Define a range for the :only parameter to child.
This creates an object that child interprets like a standard ruby Range. However, it is customized for the use of child in the following ways:
Define the given symbol.
Recognized options include:
:bump: | The symbol to transition to when "bump" is called. Default is to remain on the same value. |
Raises Versionomy::Errors::TypeMismatchError if called when the current field is not of type :symbol.
Raises Versionomy::Errors::SymbolRedefinedError if the given symbol name is already defined.
Provide a "bump" procedure. The given block should take a value, and return the value to transition to. If you return nil, the value will remain the same.
Provide a "canonicalize" procedure. The given block should take a value and return a canonicalized value. Return nil if the given value is illegal.
Provide a "compare" procedure. The given block should take two values and compare them. It should return a negative integer if the first is less than the second, a positive integer if the first is greater than the second, or 0 if the two values are equal. If the values cannot be compared, return nil.