Class: Ryakuzu::MigrationText
- Inherits:
-
Object
- Object
- Ryakuzu::MigrationText
- Defined in:
- lib/ryakuzu/tools/migration_text.rb
Instance Attribute Summary collapse
-
#column ⇒ Object
readonly
Returns the value of attribute column.
-
#default ⇒ Object
readonly
Returns the value of attribute default.
-
#table ⇒ Object
readonly
Returns the value of attribute table.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #default_migration ⇒ Object
- #full_migration ⇒ Object
-
#initialize(table, column, type, default) ⇒ MigrationText
constructor
A new instance of MigrationText.
- #type_migration ⇒ Object
Constructor Details
#initialize(table, column, type, default) ⇒ MigrationText
Returns a new instance of MigrationText.
5 6 7 8 9 10 11 |
# 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 |
Instance Attribute Details
#column ⇒ Object (readonly)
Returns the value of attribute column.
3 4 5 |
# File 'lib/ryakuzu/tools/migration_text.rb', line 3 def column @column end |
#default ⇒ Object (readonly)
Returns the value of attribute default.
3 4 5 |
# File 'lib/ryakuzu/tools/migration_text.rb', line 3 def default @default end |
#table ⇒ Object (readonly)
Returns the value of attribute table.
3 4 5 |
# File 'lib/ryakuzu/tools/migration_text.rb', line 3 def table @table end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
3 4 5 |
# File 'lib/ryakuzu/tools/migration_text.rb', line 3 def text @text end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
3 4 5 |
# File 'lib/ryakuzu/tools/migration_text.rb', line 3 def type @type end |
Instance Method Details
#default_migration ⇒ Object
21 22 23 24 |
# 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 ⇒ Object
13 14 15 |
# File 'lib/ryakuzu/tools/migration_text.rb', line 13 def full_migration default.empty? ? type_migration : default_migration end |
#type_migration ⇒ Object
17 18 19 |
# File 'lib/ryakuzu/tools/migration_text.rb', line 17 def type_migration text.concat "add_column :#{table.tableize}, :#{column}, :#{type.downcase}" end |