Class: SDL::Association::BelongsTo

Inherits:
SDL::Association show all
Includes:
Field::ColumnOptions
Defined in:
lib/sdl/association.rb

Overview

Indicates a one-to-one connection with another Model

Instance Method Summary collapse

Constructor Details

This class inherits a constructor from SDL::Field

Instance Method Details

#column_nameName

The name of the column

Returns:



61
62
63
# File 'lib/sdl/association.rb', line 61

def column_name
  Name.new("#{name}_id")
end

#defaultObject Originally defined in module Field::ColumnOptions

A default value for this field

Returns:

  • (Object)

#foreign_key?Boolean

Should this field have a foreign key?

Returns:

  • (Boolean)


55
56
57
# File 'lib/sdl/association.rb', line 55

def foreign_key?
  options.fetch(:foreign_key, false)
end

#index?Boolean Originally defined in module Field::ColumnOptions

Should this field have an index?

Returns:

  • (Boolean)

#limitInteger Originally defined in module Field::ColumnOptions

A limit for the field

Returns:

  • (Integer)

#precisionInteger Originally defined in module Field::ColumnOptions

A precision for the field

Returns:

  • (Integer)

#scaleInteger Originally defined in module Field::ColumnOptions

A scale for the field

Returns:

  • (Integer)

#typeSymbol

The type of field

Returns:

  • (Symbol)


49
50
51
# File 'lib/sdl/association.rb', line 49

def type
  :belongs_to
end

#unique?Boolean Originally defined in module Field::ColumnOptions

Is this field unique?

Returns:

  • (Boolean)