Module: PgGraph::Type
- Defined in:
- lib/pg_graph.rb,
lib/pg_graph/type/read.rb,
lib/pg_graph/type/type.rb,
lib/pg_graph/type/dump_type.rb
Defined Under Namespace
Modules: TableObject Classes: ArrayType, Column, CompositeType, Database, Error, Field, KeyNotFound, KindRecordColumn, MmTableColumn, NmTableColumn, Node, PgCatalogSchema, RecordColumn, RecordType, Schema, SchemaObject, SimpleColumn, SimpleType, SubRecordColumn, SuperRecordColumn, Table, TableColumn, TableType, Type
Class Method Summary collapse
-
.===(element) ⇒ Object
Make the Type module pretend to have Database object instances.
-
.new(arg, reflections = nil, schema = nil, ignore: []) ⇒ Object
:call-seq: new(meta, reflect = nil) new(pg_conn, reflect = nil).
Class Method Details
.===(element) ⇒ Object
Make the Type module pretend to have Database object instances
73 |
# File 'lib/pg_graph.rb', line 73 def self.===(element) element.is_a?(PgGraph::Type::Database) or super end |
.new(arg, reflections = nil, schema = nil, ignore: []) ⇒ Object
:call-seq:
new(, reflect = nil)
new(pg_conn, reflect = nil)
The reflections
argument can be a Reflector object, an yaml array, a file name, a PgConn object, or nil. If reflections
is a PgConn object, the schema
argument should be set to the schema containing the ‘reflections’ table. The ignore
option is a list of schema names to exclude from the type system
Note that together with ::=== and Database#is_a? this makes Type::Database pretend it is an instance of the Type module
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/pg_graph.rb', line 53 def self.new(arg, reflections = nil, schema = nil, ignore: []) constrain arg, PgMeta, PgConn constrain reflections, Reflector, Array, String, PgConn, NilClass = case arg when PgMeta; arg when PgConn; PgMeta.new(arg) end reflector = case reflections when Reflector; reflections when Array; Reflector.load_yaml(reflections) when String; Reflector.load_file(reflections) when PgConn; Reflector.load_table(reflections, schema) when NilClass; Reflector.new end Database.new(.name, reflector).read(, ignore: ignore) end |