Class

ActiveRecord::ConnectionAdapters::Column

Inheritance
< Object

An abstract definition of a column in a table.

Classes & Modules

Constants

Name   Description
FALSE_VALUES = [false, 0, '0', 'f', 'F', 'false', 'FALSE'].to_set
TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE'].to_set

Attributes

Name Visibility R/W Description
default public R
limit public R
name public R
null public R
precision public R
primary public RW
scale public R
sql_type public R
type public R

Methods

Class

Visibility Signature
public binary_to_string (value)
public new (name, default, sql_type = nil, null = true)
public string_to_binary (value)
public string_to_date (string)
public string_to_dummy_time (string)
public string_to_time (string)
public value_to_boolean (value)
public value_to_decimal (value)
protected fallback_string_to_date (string)
protected fallback_string_to_time (string)
protected fast_string_to_date (string)
protected fast_string_to_time (string)
protected microseconds (time)
protected new_date (year, mon, mday)
protected new_time (year, mon, mday, hour, min, sec, microsec)

Instance

Visibility Signature
public extract_default (default)
public has_default? ()
public human_name ()
public klass ()
public number? ()
public text? ()
public type_cast (value)
public type_cast_code (var_name)

Class Method Detail

binary_to_string(value)

Used to convert from BLOBs to Strings

new(name, default, sql_type = nil, null = true)

Instantiates a new column in the table.

name is the column‘s name, such as supplier_id in supplier_id int(11). default is the type-casted default value, such as new in sales_stage varchar(20) default ‘new. sql_type is only used to extract the column‘s length, if necessary. For example +60+ in company_name varchar(60). null determines if this column allows NULL values.

string_to_binary(value)

Used to convert from Strings to BLOBs

string_to_date(string)

string_to_dummy_time(string)

string_to_time(string)

value_to_boolean(value)

convert something to a boolean

value_to_decimal(value)

convert something to a BigDecimal

fallback_string_to_date(string)

fallback_string_to_time(string)

fast_string_to_date(string)

fast_string_to_time(string)

Doesn‘t handle time zones.

microseconds(time)

‘0.123456’ -> 123456 ‘1.123456’ -> 123456

new_date(year, mon, mday)

new_time(year, mon, mday, hour, min, sec, microsec)

Instance Method Detail

extract_default(default)

has_default?()

human_name()

Returns the human name of the column name.

Examples
 Column.new('sales_stage', ...).human_name # => 'Sales stage'

klass()

Returns the Ruby class that corresponds to the abstract data type.

number?()

Returns true if the column is either of type integer, float or decimal.

text?()

Returns true if the column is either of type string or text.

type_cast(value)

Casts value (which is a String) to an appropriate instance.

type_cast_code(var_name)