Module: ActiveGraph::Core::Schema

Included in:
Base
Defined in:
lib/active_graph/core/schema.rb

Instance Method Summary collapse

Instance Method Details

#constraint_owned?(record) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/active_graph/core/schema.rb', line 46

def constraint_owned?(record)
  record[:owningConstraint]
end

#constraintsObject



30
31
32
# File 'lib/active_graph/core/schema.rb', line 30

def constraints
  raw_constraints.select(&method(:constraint_filter)).map { |row| definition(row, :constraint_cypher).merge(type: :uniqueness) }
end

#editionObject



8
9
10
# File 'lib/active_graph/core/schema.rb', line 8

def edition
  component[:edition]
end

#enterprise?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/active_graph/core/schema.rb', line 12

def enterprise?
  edition == 'enterprise'
end

#indexesObject



20
21
22
# File 'lib/active_graph/core/schema.rb', line 20

def indexes
  normalize(raw_indexes, *%i[type state])
end

#normalize(result, *extra) ⇒ Object



24
25
26
27
28
# File 'lib/active_graph/core/schema.rb', line 24

def normalize(result, *extra)
  result.map do |row|
    definition(row, :index_cypher).merge(extra.to_h { |key| [key, row[key].to_sym] })
  end
end

#raw_indexesObject



40
41
42
43
44
# File 'lib/active_graph/core/schema.rb', line 40

def raw_indexes
  read_transaction do
    query('SHOW INDEXES YIELD *', {}, skip_instrumentation: true).reject { |row| row[:type] == 'LOOKUP' }
  end
end

#versionObject



4
5
6
# File 'lib/active_graph/core/schema.rb', line 4

def version
  Gem::Version.new(component[:versions][0])
end

#version?(requirement) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/active_graph/core/schema.rb', line 16

def version?(requirement)
  Gem::Requirement.create(requirement).satisfied_by?(version)
end