Class: MigrationDefs::Column
- Inherits:
-
AbstractMigrationClass
- Object
- AbstractMigrationClass
- MigrationDefs::Column
- Defined in:
- lib/migration_defs.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#option ⇒ Object
Returns the value of attribute option.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #get_str(prefix = 't.') ⇒ Object
-
#initialize(type, name = '', *p_option) ⇒ Column
constructor
A new instance of Column.
- #set_option(key, val) ⇒ Object
Constructor Details
#initialize(type, name = '', *p_option) ⇒ Column
Returns a new instance of Column.
190 191 192 193 194 195 196 |
# File 'lib/migration_defs.rb', line 190 def initialize(type, name = '', *p_option) return nil if !ColumnType.has_key?(type) @type = type @name = name @option = ColumnOption.new end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
188 189 190 |
# File 'lib/migration_defs.rb', line 188 def name @name end |
#option ⇒ Object
Returns the value of attribute option.
188 189 190 |
# File 'lib/migration_defs.rb', line 188 def option @option end |
#type ⇒ Object
Returns the value of attribute type.
188 189 190 |
# File 'lib/migration_defs.rb', line 188 def type @type end |
Instance Method Details
#get_str(prefix = 't.') ⇒ Object
213 214 215 216 217 |
# File 'lib/migration_defs.rb', line 213 def get_str(prefix = 't.') result = prefix + @type result += " :#{@name}" if (@type != 'timestamps') && (@type != 'attachment') && (@type != 'belongs_to') result += @option.get_str end |
#set_option(key, val) ⇒ Object
198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
# File 'lib/migration_defs.rb', line 198 def set_option(key, val) case key when 'limit' @option.limit = val.to_i when 'default' @option.default = val when 'null' @option.null = (val == 'true') when 'precision' @option.precision = val.to_i when 'scale' @option.scale = val.to_i end end |