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 = true, precision = nil, scale = nil) ⇒ ColumnOption

Returns a new instance of ColumnOption.



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

def initialize(limit = nil, default = nil, is_null = true, 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.



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

def default
  @default
end

#limitObject

Returns the value of attribute limit.



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

def limit
  @limit
end

#nullObject

Returns the value of attribute null.



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

def null
  @null
end

#precisionObject

Returns the value of attribute precision.



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

def precision
  @precision
end

#scaleObject

Returns the value of attribute scale.



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

def scale
  @scale
end

Instance Method Details

#get_strObject



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

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