Class: PgGraph::Type::Node

Inherits:
HashTree::Set
  • Object
show all
Includes:
Constrain
Defined in:
lib/pg_graph/type/type.rb,
lib/pg_graph/type/dump_type.rb

Direct Known Subclasses

Database, Field, Schema, SchemaObject

Instance Method Summary collapse

Constructor Details

#initialize(parent, name, **opts) ⇒ Node

:call-seq: initialize(database, name, attach: true)



21
22
23
24
25
# File 'lib/pg_graph/type/type.rb', line 21

def initialize(parent, name, **opts)
  constrain parent, Node, NilClass
  constrain name, String, NilClass
  super
end

Instance Method Details

#dump(children = self.children.values.sort_by(&:name), link_info: false, super_table: nil) ⇒ Object



5
6
7
8
9
# File 'lib/pg_graph/type/dump_type.rb', line 5

def dump(children = self.children.values.sort_by(&:name), link_info: false, super_table: nil)
  print identifier + (super_table ? " < #{super_table}" : "")
  puts
  indent { children.each { |child| child.dump(link_info: link_info) } }
end

#guidObject



9
# File 'lib/pg_graph/type/type.rb', line 9

def guid() root.name + "." + uid end

#identifierObject

The Ruby model identifier of the object. It corresponds to #name



14
# File 'lib/pg_graph/type/type.rb', line 14

def identifier() PgGraph.inflector.camelize(name) end

#inspect(payload = inspect_inner) ⇒ Object



27
28
29
# File 'lib/pg_graph/type/type.rb', line 27

def inspect(payload = inspect_inner)
  "#<#{self.class}:#{name.inspect}#{payload ? " #{payload}" : ""}>"
end

#inspect_innerObject



31
# File 'lib/pg_graph/type/type.rb', line 31

def inspect_inner() nil end

#schema_identifierObject

The full Ruby model identifier of the object within a database. It corresponds to #uid



18
# File 'lib/pg_graph/type/type.rb', line 18

def schema_identifier() identifier end