Class: MigrationDefs::ColumnOption

Inherits:
AbstractMigrationClass show all
Defined in:
lib/migration_defs.rb

Constant Summary collapse

Description =
{
  'limit' => 'カラムの桁数',
  'default' => 'デフォルトの値',
  'null' => 'nullを許可するか',
  'precision' => '数値の桁数',
  'scale' => '小数点以下の桁数',
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(limit = nil, default = nil, is_null = false, precision = nil, scale = nil) ⇒ ColumnOption

Returns a new instance of ColumnOption.



168
169
170
171
172
173
174
# File 'lib/migration_defs.rb', line 168

def initialize(limit = nil, default = nil, is_null = false, precision = nil, scale = nil)
   @limit = limit
   @default = default
   @null	= is_null
   @precision = precision
   @scale = scale
end

Instance Attribute Details

#defaultObject

Returns the value of attribute default.



158
159
160
# File 'lib/migration_defs.rb', line 158

def default
  @default
end

#limitObject

Returns the value of attribute limit.



158
159
160
# File 'lib/migration_defs.rb', line 158

def limit
  @limit
end

#nullObject

Returns the value of attribute null.



158
159
160
# File 'lib/migration_defs.rb', line 158

def null
  @null
end

#precisionObject

Returns the value of attribute precision.



158
159
160
# File 'lib/migration_defs.rb', line 158

def precision
  @precision
end

#scaleObject

Returns the value of attribute scale.



158
159
160
# File 'lib/migration_defs.rb', line 158

def scale
  @scale
end

Instance Method Details

#get_strObject



176
177
178
179
180
181
182
183
184
# File 'lib/migration_defs.rb', line 176

def get_str
  result = ''
  result += ", :limit => #{@limit.to_s}" if !@limit.blank? && @limit != 0
  result += ", :default => #{@default.to_s}" if !@default.blank?
  result += ", :null => #{@null.to_s}" if !@null.blank?
  result += ", :precision => #{@precision.to_s}" if !@precision.nil? && @precision != 0
  result += ", :scale => #{@scale.to_s}" if !@scale.nil? && @scale != 0
  result
end