Class: MigrationValidators::Spec::Support::TableWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/migration_validators/spec/support/table_wrapper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(table_name, db) ⇒ TableWrapper

Returns a new instance of TableWrapper.



7
8
9
10
# File 'lib/migration_validators/spec/support/table_wrapper.rb', line 7

def initialize table_name, db
  @table_name = table_name
  @db = db
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args) ⇒ Object



17
18
19
20
21
# File 'lib/migration_validators/spec/support/table_wrapper.rb', line 17

def method_missing method_name, *args
  return MigrationValidators::Spec::Support::ColumnWrapper.new(method_name, self, @db) if @db.column_exists?(table_name, method_name)

  old_method_missing method_name, *args
end

Instance Attribute Details

#table_nameObject

Returns the value of attribute table_name.



5
6
7
# File 'lib/migration_validators/spec/support/table_wrapper.rb', line 5

def table_name
  @table_name
end

Instance Method Details

#dropObject



12
13
14
# File 'lib/migration_validators/spec/support/table_wrapper.rb', line 12

def drop
  @db.drop_table(table_name) if @db.table_exists?(table_name)
end

#old_method_missingObject



16
# File 'lib/migration_validators/spec/support/table_wrapper.rb', line 16

alias_method :old_method_missing, :method_missing