Class: Dbtools::Database::DatabaseData

Inherits:
Object
  • Object
show all
Defined in:
lib/dbtools/database/database_data.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ DatabaseData

Returns a new instance of DatabaseData.



6
7
8
9
# File 'lib/dbtools/database/database_data.rb', line 6

def initialize(name)
  @name = name
  @tables = Hash.new
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/dbtools/database/database_data.rb', line 5

def name
  @name
end

#tablesObject (readonly)

Returns the value of attribute tables.



5
6
7
# File 'lib/dbtools/database/database_data.rb', line 5

def tables
  @tables
end

Instance Method Details

#add_table(table_name, schema) ⇒ Object

Add table if it doesn’t exist yet.



12
13
14
15
16
# File 'lib/dbtools/database/database_data.rb', line 12

def add_table(table_name, schema)
  key = "#{schema}.#{table_name}"
  @tables[key] = Table.new(table_name, schema) unless @tables.include?(table_name)
  return @tables[key]
end

#to_sObject



18
19
20
21
22
23
24
# File 'lib/dbtools/database/database_data.rb', line 18

def to_s
  output = "#{@name}: \n"
  @tables.each do |k, v|
    output << v.to_s << "\n"
  end
  return output
end