class Ryakuzu::MigrationText
Attributes
column[R]
default[R]
table[R]
text[R]
type[R]
Public Class Methods
new(table, column, type, default)
click to toggle source
# File lib/ryakuzu/tools/migration_text.rb, line 5 def initialize(table, column, type, default) @table = table @column = column @type = type @default = default @text = "remove_column :#{@table.tableize}, :#{@column}\n" end
Public Instance Methods
default_migration()
click to toggle source
# File lib/ryakuzu/tools/migration_text.rb, line 21 def default_migration val_def = create_full_text text.concat "add_column :#{table.tableize}, :#{column}, :#{type.downcase}, default: #{val_def}" end
full_migration()
click to toggle source
# File lib/ryakuzu/tools/migration_text.rb, line 13 def full_migration default.empty? ? type_migration : default_migration end
type_migration()
click to toggle source
# File lib/ryakuzu/tools/migration_text.rb, line 17 def type_migration text.concat "add_column :#{table.tableize}, :#{column}, :#{type.downcase}" end
Private Instance Methods
create_full_text()
click to toggle source
# File lib/ryakuzu/tools/migration_text.rb, line 28 def create_full_text arr = %w(Integer Float Decimal Binary Boolean) arr.any? { |e| e == type } ? "#{default}" : "'#{default}'" end