Class: Arfy::MigrationBuilder::GenericMigration

Inherits:
Object
  • Object
show all
Defined in:
lib/arfy/migration_builder/generic_migration.rb

Direct Known Subclasses

ColumnMigration, CreateTable, DropTable, RenameTable

Instance Method Summary collapse

Constructor Details

#initialize(table_name) ⇒ GenericMigration

Returns a new instance of GenericMigration.



14
15
16
# File 'lib/arfy/migration_builder/generic_migration.rb', line 14

def initialize(table_name)
  @table_name = table_name
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object (private)



90
91
92
93
94
95
# File 'lib/arfy/migration_builder/generic_migration.rb', line 90

def method_missing(method, *args)
  column_name = args[0]
  column_type = method
  column_options = args[1]
  return super unless add_column(column_name, column_type, column_options)
end

Instance Method Details

#code_for_templateObject



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/arfy/migration_builder/generic_migration.rb', line 25

def code_for_template
  code = {:change_code => "", :up_code => "", :down_code => ""}

  if im_reversible?
    code[:change_code] = change_code
  else
    code[:up_code] = up_code
    code[:down_code] = down_code
  end

  code
end

#respond_to?(method, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
21
22
23
# File 'lib/arfy/migration_builder/generic_migration.rb', line 18

def respond_to?(method, include_private=false)
  if COLUMN_VALID_TYPES.include? method
    return true
  end
  super
end