Lustra::Model::Column(T, C)
Inherits Lustra::ErrorMessages < Reference < Object
A column of a Model Provide some methods like:
- Informations persistance (value before, value changed?)
- Raise error if we try to access the value of a field
which is not gathered through the query system (uninitialized column).
Or use the
get_defto get with default value
Constants
Constructors
Instance methods
Returns the change for this column as a tuple of {old_value, new_value}.
Returns nil if the column hasn't changed or if old_value is not defined.
user.email = "new@test.com"
user.email_column.change # => {"old@test.com", "new@test.com"}
user.name_column.change # => nil (if not changed)
Completely clear the column, remove both value and old_value and turning the column in a non-defined state.
Inspect this column. If a column is not loaded (e.g. not defined once), it will show "#undef". If a column is dirty (e.g. change hasn't be saved), it will show a "*" after the value.
Reset the current field.
Restore the old_value state to current value.
Reset the flag changed to false.
Return the database converted value using the converter
Returns the current value of this column or default if the value is undefined.
Returns the current value of this column. If the value has never been initialized, throw an exception
Set the value of the column to the value x. If x is not equal to the old value, then the column changed?
flag is set to true.