Class: PgMeta::Schema
Instance Attribute Summary collapse
-
#functions ⇒ Object
readonly
Hash of functions.
-
#owner ⇒ Object
readonly
Owner of the schema.
-
#procedures ⇒ Object
readonly
Hash of procedures.
-
#tables ⇒ Object
readonly
Hash of tables and views.
Attributes inherited from Node
Instance Method Summary collapse
-
#[](sid) ⇒ Object
Lookup schema objects by sid.
-
#hidden=(hide) ⇒ Object
Set hidden property.
-
#hidden? ⇒ Boolean
True if schema is hidden.
-
#initialize(database, name, owner, hidden: false) ⇒ Schema
constructor
A new instance of Schema.
- #to_h ⇒ Object
-
#views ⇒ Object
Hash of views.
Methods inherited from Node
#dump, #dump_value, #guid, #inspect, #sid, #to_s, #to_yaml, #uid
Constructor Details
#initialize(database, name, owner, hidden: false) ⇒ Schema
Returns a new instance of Schema.
136 137 138 139 140 141 142 143 144 |
# File 'lib/pg_meta/meta.rb', line 136 def initialize(database, name, owner, hidden: false) super(database, name) @owner = owner @tables = {} @functions = {} @procedures = {} @hidden = hidden database.schemas[name] = self end |
Instance Attribute Details
#functions ⇒ Object (readonly)
Hash of functions
131 132 133 |
# File 'lib/pg_meta/meta.rb', line 131 def functions @functions end |
#owner ⇒ Object (readonly)
Owner of the schema
122 123 124 |
# File 'lib/pg_meta/meta.rb', line 122 def owner @owner end |
#procedures ⇒ Object (readonly)
Hash of procedures
134 135 136 |
# File 'lib/pg_meta/meta.rb', line 134 def procedures @procedures end |
#tables ⇒ Object (readonly)
Hash of tables and views. TODO: Rename #relations
125 126 127 |
# File 'lib/pg_meta/meta.rb', line 125 def tables @tables end |
Instance Method Details
#[](sid) ⇒ Object
Lookup schema objects by sid
147 |
# File 'lib/pg_meta/meta.rb', line 147 def [](sid) = database["#{uid}.#{sid}"] |
#hidden=(hide) ⇒ Object
Set hidden property
153 154 155 156 157 158 159 160 |
# File 'lib/pg_meta/meta.rb', line 153 def hidden=(hide) if @hidden database.schemas[name] = database.hidden_schemas.delete(name) if !hide else database.hidden_schemas[name] = database.schemas.delete(name) if hide end @hidden = hide end |
#hidden? ⇒ Boolean
True if schema is hidden. This can be set dynamically
150 |
# File 'lib/pg_meta/meta.rb', line 150 def hidden?() @hidden end |
#to_h ⇒ Object
162 |
# File 'lib/pg_meta/meta.rb', line 162 def to_h() attrs_to_h(:name, :owner, :tables, :views, :functions, :procedures) end |
#views ⇒ Object
Hash of views
128 |
# File 'lib/pg_meta/meta.rb', line 128 def views() @views ||= @tables.select { |_, table| table.view? } end |