module ActiveGraph::Base

To contain any base login for Node/Relationship which is external to the main classes

Public Class Methods

driver() click to toggle source

private?

   # File lib/active_graph/base.rb
18 def driver
19   (@driver ||= establish_driver).tap do |driver|
20     fail 'No driver defined!' if driver.nil?
21   end
22 end
driver=(driver) click to toggle source

Should support setting driver via config options

   # File lib/active_graph/base.rb
39 def driver=(driver)
40   @driver&.close
41   @driver = driver
42 end
establish_driver() click to toggle source
   # File lib/active_graph/base.rb
28 def establish_driver
29   @establish_driver_block.call if @establish_driver_block
30 end
label_object(label_name) click to toggle source
   # File lib/active_graph/base.rb
62 def label_object(label_name)
63   ActiveGraph::Core::Label.new(label_name)
64 end
logger() click to toggle source
   # File lib/active_graph/base.rb
66 def logger
67   @logger ||= (ActiveGraph::Config[:logger] || ActiveSupport::Logger.new(STDOUT))
68 end
magic_query(*args) click to toggle source
   # File lib/active_graph/base.rb
54 def magic_query(*args)
55   if args.empty? || args.map(&:class) == [Hash]
56     new_query(*args)
57   else
58     query(*args)
59   end
60 end
new_query(options = {}) click to toggle source
   # File lib/active_graph/base.rb
49 def new_query(options = {})
50   validate_model_schema!
51   ActiveGraph::Core::Query.new(options)
52 end
on_establish_driver(&block) click to toggle source
   # File lib/active_graph/base.rb
24 def on_establish_driver(&block)
25   @establish_driver_block = block
26 end
query(*args) click to toggle source
Calls superclass method ActiveGraph::Core::Querable#query
   # File lib/active_graph/base.rb
32 def query(*args)
33   transaction do
34     super(*args)
35   end
36 end
validating_transaction(&block) click to toggle source
   # File lib/active_graph/base.rb
44 def validating_transaction(&block)
45   validate_model_schema!
46   transaction(&block)
47 end

Private Class Methods

validate_model_schema!() click to toggle source
   # File lib/active_graph/base.rb
72 def validate_model_schema!
73   ActiveGraph::ModelSchema.validate_model_schema! unless ActiveGraph::Migrations.currently_running_migrations
74 end