Class: DataMigrations::Table

Inherits:
Object
  • Object
show all
Defined in:
lib/data_migrations/table.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Table

Returns a new instance of Table.



7
8
9
# File 'lib/data_migrations/table.rb', line 7

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/data_migrations/table.rb', line 5

def name
  @name
end

Instance Method Details

#column(name) ⇒ Object



19
20
21
# File 'lib/data_migrations/table.rb', line 19

def column(name)
  columns.detect { |column| column.name.to_s == name.to_s } || raise_column_not_found(name)
end

#column_namesObject



15
16
17
# File 'lib/data_migrations/table.rb', line 15

def column_names
  columns.map(&:name)
end

#columnsObject



11
12
13
# File 'lib/data_migrations/table.rb', line 11

def columns
  connection.columns(name)
end

#quoted_nameObject



23
24
25
# File 'lib/data_migrations/table.rb', line 23

def quoted_name
  connection.quote_table_name(name)
end

#raise_column_not_found(name) ⇒ Object



27
28
29
# File 'lib/data_migrations/table.rb', line 27

def raise_column_not_found(name)
  raise "could not find column #{name} on #{self.name}"
end