class Clear::Model::Column(T, C)
- Clear::Model::Column(T, C)
- Reference
- Object
Overview
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_def
to get with default value
Included Modules
Defined in:
clear/model/column.crConstant Summary
-
UNKNOWN =
UnknownClass.new
Constructors
Instance Method Summary
- #changed? : Bool
-
#clear
Completely clear the column, remove both
#value
and#old_value
and turning the column in a non-defined state. -
#clear_change_flag
Reset
#changed?
flag tofalse
. -
#defined?
Check whether the column is defined or not.
-
#dirty!
Reset
#changed?
flag totrue
. - #has_db_default? : Bool
-
#inspect
Inspect this column.
- #name : String
-
#nilable?
Return
true
if the value is an union of a Type with Nilable,false
otherwise. - #old_value : T | UnknownClass
-
#reset(x : T | Nil)
Reset the current field.
- #reset_convert(x)
-
#revert
If the column is dirty (e.g the value has been changed), return to the previous state.
- #set(x : T | Nil)
- #set_convert(x)
-
#to_sql_value(default = nil) : Clear::SQL::Any
Return the database converted value using the converter
-
#value(default : X) : T | X forall X
Returns the current value of this column or
default
if the value is undefined. -
#value : T
Returns the current value of this column.
-
#value=(x : T)
Set the value of the column to the value
x
.
Instance methods inherited from module Clear::ErrorMessages
build_error_message(message : String, ways_to_resolve : Tuple | Array = Tuple.new, manual_pages : Tuple | Array = Tuple.new)
build_error_message,
converter_error(from, to)
converter_error,
format_width(x, w = 80)
format_width,
illegal_setter_access_to_undefined_column(name)
illegal_setter_access_to_undefined_column,
lack_of_primary_key(model_name)
lack_of_primary_key,
migration_already_down(number)
migration_already_down,
migration_already_up(number)
migration_already_up,
migration_drop_irreversible(name)
migration_drop_irreversible,
migration_irreversible(name = nil, operation = nil)
migration_irreversible,
migration_not_found(number)
migration_not_found,
migration_not_unique(numbers)
migration_not_unique,
no_migration_yet(version)
no_migration_yet,
null_column_mapping_error(name, type)
null_column_mapping_error,
order_by_error_invalid_order(current_order)
order_by_error_invalid_order,
polymorphic_nil(through)
polymorphic_nil,
polymorphic_unknown_class(class_name)
polymorphic_unknown_class,
query_building_error(message)
query_building_error,
uid_not_found(class_name)
uid_not_found,
uninitialized_db_connection(connection)
uninitialized_db_connection
Constructor Detail
Instance Method Detail
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