Class: SDL::Enum

Inherits:
Field show all
Includes:
Field::ColumnOptions
Defined in:
lib/sdl/enum.rb

Overview

A field of a Model that has a predefined list of possible values

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:


29
30
31
# File 'lib/sdl/enum.rb', line 29

def column_name
  name
end

#defaultName

A default value for this field

Returns:


17
18
19
# File 'lib/sdl/enum.rb', line 17

def default
  Name.new(options[:default].to_s) if options[:default]
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)

11
12
13
# File 'lib/sdl/enum.rb', line 11

def type
  :enum
end

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

Is this field unique?

Returns:

  • (Boolean)

#valuesArray<Name>

The possible values for the enum

Returns:


23
24
25
# File 'lib/sdl/enum.rb', line 23

def values
  options.fetch(:values, []).map { |value| Name.new(value.to_s) }
end