Class: ActiveCypher::Schema::Writer::Cypher

Inherits:
Object
  • Object
show all
Defined in:
lib/active_cypher/schema/writer/cypher.rb

Instance Method Summary collapse

Constructor Details

#initialize(catalog, vendor) ⇒ Cypher

Returns a new instance of Cypher.



7
8
9
10
# File 'lib/active_cypher/schema/writer/cypher.rb', line 7

def initialize(catalog, vendor)
  @catalog = catalog
  @vendor  = vendor
end

Instance Method Details

#to_sObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/active_cypher/schema/writer/cypher.rb', line 12

def to_s
  sections = []
  sections << constraint_lines(@catalog.constraints)
  sections << index_lines(@catalog.indexes.select { |i| i.element == :node }, :node)
  sections << index_lines(@catalog.indexes.select { |i| i.element == :relationship }, :relationship)
  if @vendor == :memgraph
    sections << node_type_lines(@catalog.node_types)
    sections << edge_type_lines(@catalog.edge_types)
  end
  sections.reject(&:empty?).join("\n")
end