Class: PgGraph::Data::Schema
- Inherits:
-
DatabaseObject
- Object
- Node
- DatabaseObject
- PgGraph::Data::Schema
- Defined in:
- lib/pg_graph/data/data.rb
Instance Attribute Summary collapse
-
#database ⇒ Object
readonly
Returns the value of attribute database.
Attributes inherited from Node
Instance Method Summary collapse
-
#data ⇒ Object
(also: #to_h)
Return schema as a hash from table name to table hash.
-
#each(&block) ⇒ Object
Iterate tables.
-
#initialize(database, type) ⇒ Schema
constructor
A new instance of Schema.
-
#tables ⇒ Object
List of Table objects.
-
#to_yaml ⇒ Object
end.
Methods inherited from DatabaseObject
#<=>, #dot, #guid, #name, #uid
Methods inherited from Node
#inspect, #object, #value, #value_type
Constructor Details
#initialize(database, type) ⇒ Schema
Returns a new instance of Schema.
192 193 194 195 196 197 198 199 |
# File 'lib/pg_graph/data/data.rb', line 192 def initialize(database, type) constrain database, Database constrain type, PgGraph::Type::Schema @database = database super(type) @impl = {} # A hash from table name to Table object type.tables.each { |table| @impl[table.name] = Table.new(self, table) } end |
Instance Attribute Details
#database ⇒ Object (readonly)
Returns the value of attribute database.
187 188 189 |
# File 'lib/pg_graph/data/data.rb', line 187 def database @database end |
Instance Method Details
#data ⇒ Object Also known as: to_h
Return schema as a hash from table name to table hash
208 |
# File 'lib/pg_graph/data/data.rb', line 208 def data() @impl.map { |k,v| [k, v.data] }.to_h end |
#each(&block) ⇒ Object
Iterate tables
205 |
# File 'lib/pg_graph/data/data.rb', line 205 def each(&block) tables.each { |table| yield table } end |
#tables ⇒ Object
List of Table objects
190 |
# File 'lib/pg_graph/data/data.rb', line 190 def tables() @impl.values end |
#to_yaml ⇒ Object
end
214 |
# File 'lib/pg_graph/data/data.rb', line 214 def to_yaml() @impl.map { |k,v| [k, v.to_yaml] }.to_h end |