Module: ActiveGraph::Base
Overview
To contain any base login for Node/Relationship which is external to the main classes
Constant Summary
Core::Instrumentable::EMPTY, Core::Instrumentable::NEWLINE_W_SPACES
Class Method Summary
collapse
constraint_owned?, constraints, edition, enterprise?, indexes, normalize, raw_indexes, version, version?
Class Method Details
.driver ⇒ Object
15
16
17
18
19
|
# File 'lib/active_graph/base.rb', line 15
def driver
(@driver ||= establish_driver).tap do |driver|
fail 'No driver defined!' if driver.nil?
end
end
|
.driver=(driver) ⇒ Object
Should support setting driver via config options
36
37
38
39
|
# File 'lib/active_graph/base.rb', line 36
def driver=(driver)
@driver&.close
@driver = driver
end
|
.element(name, relationship: false) ⇒ Object
63
64
65
|
# File 'lib/active_graph/base.rb', line 63
def element(name, relationship: false)
(relationship ? Core::Type : Core::Label).new(name)
end
|
.establish_driver ⇒ Object
25
26
27
|
# File 'lib/active_graph/base.rb', line 25
def establish_driver
@establish_driver_block.call if @establish_driver_block
end
|
.label_object(label_name) ⇒ Object
59
60
61
|
# File 'lib/active_graph/base.rb', line 59
def label_object(label_name)
ActiveGraph::Core::Label.new(label_name)
end
|
.logger ⇒ Object
67
68
69
|
# File 'lib/active_graph/base.rb', line 67
def logger
@logger ||= (ActiveGraph::Config[:logger] || ActiveSupport::Logger.new(STDOUT))
end
|
.magic_query(*args) ⇒ Object
51
52
53
54
55
56
57
|
# File 'lib/active_graph/base.rb', line 51
def magic_query(*args)
if args.empty? || args.map(&:class) == [Hash]
new_query(*args)
else
query(*args)
end
end
|
.new_query(options = {}) ⇒ Object
46
47
48
49
|
# File 'lib/active_graph/base.rb', line 46
def new_query(options = {})
validate_model_schema!
ActiveGraph::Core::Query.new(options)
end
|
.on_establish_driver(&block) ⇒ Object
21
22
23
|
# File 'lib/active_graph/base.rb', line 21
def on_establish_driver(&block)
@establish_driver_block = block
end
|
.query(*args) ⇒ Object
29
30
31
32
33
|
# File 'lib/active_graph/base.rb', line 29
def query(*args)
transaction(implicit: true) do
super(*args)
end
end
|
.validating_transaction(&block) ⇒ Object
41
42
43
44
|
# File 'lib/active_graph/base.rb', line 41
def validating_transaction(&block)
validate_model_schema!
transaction(&block)
end
|