Module: ActiveGraph::Core::Schema
- Included in:
- Base
- Defined in:
- lib/active_graph/core/schema.rb
Instance Method Summary collapse
- #constraint_owned?(record) ⇒ Boolean
- #constraints ⇒ Object
- #edition ⇒ Object
- #enterprise? ⇒ Boolean
- #indexes ⇒ Object
- #normalize(result, *extra) ⇒ Object
- #raw_indexes ⇒ Object
- #version ⇒ Object
- #version?(requirement) ⇒ Boolean
Instance Method Details
#constraint_owned?(record) ⇒ Boolean
46 47 48 |
# File 'lib/active_graph/core/schema.rb', line 46 def constraint_owned?(record) record[:owningConstraint] end |
#constraints ⇒ Object
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 |
#edition ⇒ Object
8 9 10 |
# File 'lib/active_graph/core/schema.rb', line 8 def edition component[:edition] end |
#enterprise? ⇒ Boolean
12 13 14 |
# File 'lib/active_graph/core/schema.rb', line 12 def enterprise? edition == 'enterprise' end |
#indexes ⇒ Object
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_indexes ⇒ Object
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 |
#version ⇒ Object
4 5 6 |
# File 'lib/active_graph/core/schema.rb', line 4 def version Gem::Version.new(component[:versions][0]) end |
#version?(requirement) ⇒ Boolean
16 17 18 |
# File 'lib/active_graph/core/schema.rb', line 16 def version?(requirement) Gem::Requirement.create(requirement).satisfied_by?(version) end |