Class: Dbtools::Database::DatabaseData
- Inherits:
-
Object
- Object
- Dbtools::Database::DatabaseData
- Defined in:
- lib/dbtools/database/database_data.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#tables ⇒ Object
readonly
Returns the value of attribute tables.
Instance Method Summary collapse
-
#add_table(table_name, schema) ⇒ Object
Add table if it doesn’t exist yet.
-
#initialize(name) ⇒ DatabaseData
constructor
A new instance of DatabaseData.
- #to_s ⇒ Object
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
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/dbtools/database/database_data.rb', line 5 def name @name end |
#tables ⇒ Object (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_s ⇒ Object
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 |