Sha256: 15085e4a366ee2ee129d42cc2a65bd6d90c65ff76092425e6b5b3ac13c19eee1
Contents?: true
Size: 1.03 KB
Versions: 2
Compression:
Stored size: 1.03 KB
Contents
module WebammToRails module Sources module Migrations class ColumnDefinition class Presenter def initialize(column:) @column = column end def render return if @column.type == 'file' if @column.type == 'enum_column' base_def = "t.integer :#{@column.name}, null: #{@column.null}" if @column.default.present? index_of_default = @column.values.index(@column.default) base_def += ", default: #{index_of_default}" end base_def else base_def = "t.#{@column.type} :#{@column.name}, null: #{@column.null}" if @column.default.present? && @column.type == 'string' base_def += ", default: '#{@column.default}'" elsif @column.default.present? base_def += ", default: #{@column.default}" end base_def end end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
webamm_to_rails-7.0.1 | lib/webamm_to_rails/sources/migrations/column_definition/presenter.rb |
webamm_to_rails-7.0.0 | lib/webamm_to_rails/sources/migrations/column_definition/presenter.rb |