Class | Versionomy::Schema::Field |
In: |
lib/versionomy/schema/field.rb
|
Parent: | Object |
Objects of this class represent fields in a schema.
Create a field with the given name.
Recognized options include:
: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 Versionomy::Schema::FieldBuilder to further customize the field, or add child fields.
Raises Versionomy::Errors::IllegalValueError if the given default value is not legal.
Adds the given child field for the given range.
If you provide a range of nil, adds the given child field as the default child for values that do not fall into any other explicitly specified range.
Otherwise, the ranges parameter must be an array of "range" objects. Each of these range objects must be either a single String, Symbol, or Integer to specify a single value; or a two-element array or a Range object (only inclusive ends are supported) to specify a range of values.
Raises Versionomy::Errors::RangeOverlapError if the specified range overlaps another previously specified range, or if more than one default child has been set.
Raises Versionomy::Errors::RangeSpecificationError if the range is incorrectly specified.
Raises Versionomy::Errors::CircularDescendantError if adding this child will result in a circular reference.
Given a value, bump it to the "next" value. Utilizes a bump procedure if given; otherwise uses default behavior depending on the type.
Given a value, return a "canonical" value for this field. Utilizes a canonicalization procedure if given; otherwise uses default behavior depending on the type.
Raises Versionomy::Errors::IllegalValueError if the given value is not legal.
Perform a standard comparison on two values. Returns an integer that may be positive, negative, or 0. Utilizes a comparison procedure if given; otherwise uses default behavior depending on the type.