activegraph 10.0.0.pre.beta.8 → 10.0.0.pre.beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/activegraph.gemspec +1 -1
- data/lib/active_graph/core.rb +5 -6
- data/lib/active_graph/core/entity.rb +11 -0
- data/lib/active_graph/core/node.rb +3 -11
- data/lib/active_graph/node/has_n/association.rb +1 -1
- data/lib/active_graph/node/initialize.rb +1 -1
- data/lib/active_graph/node/node_wrapper.rb +1 -1
- data/lib/active_graph/node/persistence.rb +1 -1
- data/lib/active_graph/node/query/query_proxy_eager_loading.rb +1 -1
- data/lib/active_graph/relationship.rb +1 -1
- data/lib/active_graph/relationship/initialize.rb +3 -3
- data/lib/active_graph/relationship/persistence.rb +2 -2
- data/lib/active_graph/relationship/persistence/query_factory.rb +1 -1
- data/lib/active_graph/relationship/property.rb +1 -4
- data/lib/active_graph/relationship/query.rb +2 -2
- data/lib/active_graph/relationship/rel_wrapper.rb +5 -5
- data/lib/active_graph/relationship/types.rb +6 -8
- data/lib/active_graph/shared/declared_properties.rb +1 -1
- data/lib/active_graph/shared/identity.rb +1 -1
- data/lib/active_graph/shared/persistence.rb +4 -4
- data/lib/active_graph/shared/query_factory.rb +1 -1
- data/lib/active_graph/undeclared_properties.rb +1 -1
- data/lib/active_graph/version.rb +1 -1
- metadata +5 -5
- data/lib/active_graph/core/relationship.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8550db7a7318c874038288f06c18b61626de59b1e15ef6da84106c655a765ddc
|
4
|
+
data.tar.gz: 917fa4fa44b7ece60ddacae791ae73fb70632743092cb51f0efd062d4114a2c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d995c7d4ca8bbc0639434f2f284f532554a65d551ce977ee1566d84b3df50b92b2565d99ed9fbb82a3d9b3a425900c813cc16213eec9b8fd0f10e3bfc2432d3
|
7
|
+
data.tar.gz: c8532396f2b1a154733ff443ea6cd846b690b723cf86db8b37efe8153ebdf71b5fc923bfcf4c2ded43016cdd1a5213fe62222e928768d12e00d0ba5f2ee65d6c
|
data/activegraph.gemspec
CHANGED
@@ -38,7 +38,7 @@ DESCRIPTION
|
|
38
38
|
s.add_development_dependency('guard-rspec')
|
39
39
|
s.add_development_dependency('guard-rubocop')
|
40
40
|
s.add_development_dependency('neo4j-rake_tasks', '>= 0.3.0')
|
41
|
-
s.add_development_dependency("neo4j-#{ENV['driver'] == 'java' ? 'java' : 'ruby'}-driver", '>= 0.4.
|
41
|
+
s.add_development_dependency("neo4j-#{ENV['driver'] == 'java' ? 'java' : 'ruby'}-driver", '>= 0.4.1')
|
42
42
|
s.add_development_dependency('os')
|
43
43
|
s.add_development_dependency('pry')
|
44
44
|
s.add_development_dependency('railties', '>= 4.0')
|
data/lib/active_graph/core.rb
CHANGED
@@ -1,15 +1,14 @@
|
|
1
|
-
require 'active_graph/transaction'
|
2
1
|
require 'active_graph/core/instrumentable'
|
2
|
+
require 'active_graph/core/entity'
|
3
|
+
require 'active_graph/core/node'
|
3
4
|
require 'active_graph/core/query'
|
4
5
|
require 'active_graph/core/record'
|
5
|
-
|
6
|
-
require 'neo4j_ruby_driver'
|
7
6
|
require 'active_graph/core/wrappable'
|
8
|
-
require 'active_graph/
|
9
|
-
require '
|
7
|
+
require 'active_graph/transaction'
|
8
|
+
require 'neo4j_ruby_driver'
|
10
9
|
|
11
10
|
Neo4j::Driver::Types::Entity.include ActiveGraph::Core::Wrappable
|
11
|
+
Neo4j::Driver::Types::Entity.prepend ActiveGraph::Core::Entity
|
12
12
|
Neo4j::Driver::Types::Node.prepend ActiveGraph::Core::Node
|
13
|
-
Neo4j::Driver::Types::Relationship.include ActiveGraph::Core::Relationship
|
14
13
|
Neo4j::Driver::StatementResult.prepend ActiveGraph::Core::Result
|
15
14
|
Neo4j::Driver::Record.prepend ActiveGraph::Core::Record
|
@@ -1,23 +1,15 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module ActiveGraph
|
4
4
|
module Core
|
5
5
|
module Node
|
6
|
-
def
|
7
|
-
|
8
|
-
def neo_id; id; end
|
9
|
-
|
10
|
-
def ==(other)
|
11
|
-
other.is_a?(Node) && neo_id == other.neo_id
|
6
|
+
def neo_id
|
7
|
+
id
|
12
8
|
end
|
13
9
|
|
14
10
|
def labels
|
15
11
|
@labels ||= super
|
16
12
|
end
|
17
|
-
|
18
|
-
def properties
|
19
|
-
@properties ||= super
|
20
|
-
end
|
21
13
|
end
|
22
14
|
end
|
23
15
|
end
|
@@ -6,7 +6,7 @@ wrapping_proc = proc do |node|
|
|
6
6
|
next node if not found_class
|
7
7
|
|
8
8
|
found_class.new.tap do |wrapped_node|
|
9
|
-
wrapped_node.init_on_load(node, node.
|
9
|
+
wrapped_node.init_on_load(node, node.properties)
|
10
10
|
end
|
11
11
|
end
|
12
12
|
Neo4j::Driver::Types::Node.wrapper_callback(wrapping_proc)
|
@@ -62,7 +62,7 @@ module ActiveGraph
|
|
62
62
|
if rel.is_a?(ActiveGraph::Relationship)
|
63
63
|
rel.instance_variable_set(direction == :in ? '@from_node' : '@to_node', node)
|
64
64
|
end
|
65
|
-
@_cache[direction == :out ? rel.
|
65
|
+
@_cache[direction == :out ? rel.start_node_id : rel.end_node_id]
|
66
66
|
.association_proxy(element.name).add_to_cache(node, rel)
|
67
67
|
end
|
68
68
|
|
@@ -4,7 +4,7 @@ module ActiveGraph
|
|
4
4
|
module Relationship
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
|
7
|
-
MARSHAL_INSTANCE_VARIABLES = [:@attributes, :@
|
7
|
+
MARSHAL_INSTANCE_VARIABLES = [:@attributes, :@type, :@_persisted_obj]
|
8
8
|
|
9
9
|
include ActiveGraph::Shared
|
10
10
|
include ActiveGraph::Relationship::Initialize
|
@@ -9,10 +9,10 @@ module ActiveGraph::Relationship
|
|
9
9
|
# @param [ActiveGraph::Relationship] to_node_id The neo_id of the ending node of this rel
|
10
10
|
# @param [String] type the relationship type
|
11
11
|
def init_on_load(persisted_rel, from_node_id, to_node_id, type)
|
12
|
-
@
|
12
|
+
@type = type
|
13
13
|
@_persisted_obj = persisted_rel
|
14
14
|
changed_attributes_clear!
|
15
|
-
@attributes = convert_and_assign_attributes(persisted_rel.
|
15
|
+
@attributes = convert_and_assign_attributes(persisted_rel.properties)
|
16
16
|
load_nodes(from_node_id, to_node_id)
|
17
17
|
end
|
18
18
|
|
@@ -21,7 +21,7 @@ module ActiveGraph::Relationship
|
|
21
21
|
init_on_load(unwrapped_reloaded,
|
22
22
|
unwrapped_reloaded.start_node_id,
|
23
23
|
unwrapped_reloaded.end_node_id,
|
24
|
-
unwrapped_reloaded.
|
24
|
+
unwrapped_reloaded.type)
|
25
25
|
self
|
26
26
|
end
|
27
27
|
end
|
@@ -47,8 +47,8 @@ module ActiveGraph::Relationship
|
|
47
47
|
validate_node_classes!
|
48
48
|
delete_has_one_rel
|
49
49
|
rel = _create_rel
|
50
|
-
return self unless rel.respond_to?(:
|
51
|
-
init_on_load(rel, from_node, to_node, @
|
50
|
+
return self unless rel.respond_to?(:properties)
|
51
|
+
init_on_load(rel, from_node, to_node, @type)
|
52
52
|
true
|
53
53
|
end
|
54
54
|
|
@@ -85,7 +85,7 @@ module ActiveGraph::Relationship::Persistence
|
|
85
85
|
def wrap!(node, res, key)
|
86
86
|
return if node.persisted? || !res.keys.include?(key)
|
87
87
|
unwrapped = res[key]
|
88
|
-
node.init_on_load(unwrapped, unwrapped.
|
88
|
+
node.init_on_load(unwrapped, unwrapped.properties)
|
89
89
|
end
|
90
90
|
|
91
91
|
def node_symbols
|
@@ -17,16 +17,13 @@ module ActiveGraph::Relationship
|
|
17
17
|
alias end_node to_node
|
18
18
|
|
19
19
|
%w(start_node end_node).each do |direction|
|
20
|
-
define_method("#{direction}
|
20
|
+
define_method("#{direction}_id") { send(direction).neo_id if direction }
|
21
21
|
end
|
22
|
-
alias from_node_neo_id start_node_neo_id
|
23
|
-
alias to_node_neo_id end_node_neo_id
|
24
22
|
|
25
23
|
# @return [String] a string representing the relationship type that will be created
|
26
24
|
def type
|
27
25
|
self.class.type
|
28
26
|
end
|
29
|
-
alias rel_type type
|
30
27
|
|
31
28
|
def initialize(attributes = nil)
|
32
29
|
super(attributes)
|
@@ -51,12 +51,12 @@ module ActiveGraph::Relationship
|
|
51
51
|
|
52
52
|
def where_query
|
53
53
|
deprecation_warning!
|
54
|
-
ActiveGraph::Base.new_query.match("#{cypher_string(:outbound)}-[r1:`#{
|
54
|
+
ActiveGraph::Base.new_query.match("#{cypher_string(:outbound)}-[r1:`#{type}`]->#{cypher_string(:inbound)}")
|
55
55
|
end
|
56
56
|
|
57
57
|
def all_query
|
58
58
|
deprecation_warning!
|
59
|
-
ActiveGraph::Base.new_query.match("#{cypher_string}-[r1:`#{
|
59
|
+
ActiveGraph::Base.new_query.match("#{cypher_string}-[r1:`#{type}`]->#{cypher_string(:inbound)}")
|
60
60
|
end
|
61
61
|
|
62
62
|
def cypher_string(dir = :outbound)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
wrapping_proc = proc do |relationship|
|
4
4
|
ActiveGraph::RelWrapping.wrapper(relationship)
|
@@ -9,9 +9,9 @@ module ActiveGraph
|
|
9
9
|
module RelWrapping
|
10
10
|
class << self
|
11
11
|
def wrapper(rel)
|
12
|
-
rel.
|
12
|
+
rel.properties.symbolize_keys!
|
13
13
|
begin
|
14
|
-
most_concrete_class = class_from_type(rel.
|
14
|
+
most_concrete_class = class_from_type(rel.type).constantize
|
15
15
|
return rel unless most_concrete_class < ActiveGraph::Relationship
|
16
16
|
most_concrete_class.new
|
17
17
|
rescue NameError => e
|
@@ -23,8 +23,8 @@ module ActiveGraph
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
def class_from_type(
|
27
|
-
ActiveGraph::Relationship::Types::WRAPPED_CLASSES[
|
26
|
+
def class_from_type(type)
|
27
|
+
ActiveGraph::Relationship::Types::WRAPPED_CLASSES[type] || ActiveGraph::Relationship::Types::WRAPPED_CLASSES[type] = type.to_s.downcase.camelize
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -14,7 +14,7 @@ module ActiveGraph
|
|
14
14
|
# and Lesson is 'EnrolledIn'." After all, that is a big part of why we have models, right? To make our lives easier?
|
15
15
|
#
|
16
16
|
# A model is added to WRAPPED_CLASSES when it is initalized AND when the `type` class method is called within a model. This means that
|
17
|
-
# it's possible a model will be added twice: once with the
|
17
|
+
# it's possible a model will be added twice: once with the type version of the model name, again with the custom type. deal_with_it.gif.
|
18
18
|
WRAPPED_CLASSES = {}
|
19
19
|
|
20
20
|
included do
|
@@ -34,16 +34,14 @@ module ActiveGraph
|
|
34
34
|
# @param [Boolean] auto Should the given_type be changed in compliance with the gem's rel decorator setting?
|
35
35
|
def type(given_type = nil, auto = false)
|
36
36
|
case
|
37
|
-
when !given_type &&
|
38
|
-
@
|
37
|
+
when !given_type && type?
|
38
|
+
@type
|
39
39
|
when given_type
|
40
40
|
assign_type!(given_type, auto)
|
41
41
|
else
|
42
42
|
assign_type!(namespaced_model_name, true)
|
43
43
|
end
|
44
44
|
end
|
45
|
-
alias rel_type type
|
46
|
-
alias _type type # should be deprecated
|
47
45
|
|
48
46
|
def namespaced_model_name
|
49
47
|
case ActiveGraph::Config[:module_handling]
|
@@ -65,14 +63,14 @@ module ActiveGraph
|
|
65
63
|
_wrapped_classes[type.to_sym] = self.name
|
66
64
|
end
|
67
65
|
|
68
|
-
def
|
69
|
-
!!@
|
66
|
+
def type?
|
67
|
+
!!@type
|
70
68
|
end
|
71
69
|
|
72
70
|
private
|
73
71
|
|
74
72
|
def assign_type!(given_type, auto)
|
75
|
-
@
|
73
|
+
@type = (auto ? decorated_rel_type(given_type) : given_type).tap do |type|
|
76
74
|
add_wrapped_class(type)
|
77
75
|
end
|
78
76
|
end
|
@@ -174,7 +174,7 @@ module ActiveGraph::Shared
|
|
174
174
|
(value.is_a?(Array) && supports_array?(key)) || !EXCLUDED_TYPES.include?(value.class)
|
175
175
|
end
|
176
176
|
|
177
|
-
# @param [Symbol] key An undeclared property value found in the _persisted_obj.
|
177
|
+
# @param [Symbol] key An undeclared property value found in the _persisted_obj.properties hash.
|
178
178
|
# Typically, this is a node's id property, which will not be registered as other properties are.
|
179
179
|
# In the future, this should probably be reworked a bit. This class should either not know or care
|
180
180
|
# about the id property or it should be in charge of it. In the meantime, this improves
|
@@ -13,7 +13,7 @@ module ActiveGraph::Shared
|
|
13
13
|
return if skip_update?
|
14
14
|
props = props_for_update
|
15
15
|
neo4j_query(query_as(:n).set(n: props))
|
16
|
-
_persisted_obj.
|
16
|
+
_persisted_obj.properties.merge!(props)
|
17
17
|
changed_attributes_clear!
|
18
18
|
end
|
19
19
|
|
@@ -30,7 +30,7 @@ module ActiveGraph::Shared
|
|
30
30
|
# @return [Hash]
|
31
31
|
def props_for_create
|
32
32
|
inject_timestamps!
|
33
|
-
props_with_defaults = inject_defaults!(
|
33
|
+
props_with_defaults = inject_defaults!(properties)
|
34
34
|
converted_props = props_for_db(props_with_defaults)
|
35
35
|
return converted_props unless self.class.respond_to?(:default_property_values)
|
36
36
|
inject_primary_key!(converted_props)
|
@@ -143,7 +143,7 @@ module ActiveGraph::Shared
|
|
143
143
|
end
|
144
144
|
|
145
145
|
# @return [Hash] all defined and none nil properties
|
146
|
-
def
|
146
|
+
def properties
|
147
147
|
attributes.reject { |_, v| v.nil? }.symbolize_keys
|
148
148
|
end
|
149
149
|
|
@@ -197,7 +197,7 @@ module ActiveGraph::Shared
|
|
197
197
|
db_values = props_for_db(hash)
|
198
198
|
neo4j_query(query_as(:n).set(n: db_values))
|
199
199
|
db_values.each_pair { |k, v| self.public_send(:"#{k}=", v) }
|
200
|
-
_persisted_obj.
|
200
|
+
_persisted_obj.properties.merge!(db_values)
|
201
201
|
changed_attributes_selective_clear!(db_values)
|
202
202
|
true
|
203
203
|
end
|
@@ -16,7 +16,7 @@ module ActiveGraph
|
|
16
16
|
alias [] read_attribute
|
17
17
|
|
18
18
|
def read_undeclared_property(name)
|
19
|
-
_persisted_obj ? _persisted_obj.
|
19
|
+
_persisted_obj ? _persisted_obj.properties[name] : (undeclared_properties && undeclared_properties[name])
|
20
20
|
end
|
21
21
|
|
22
22
|
def write_attribute(name, value)
|
data/lib/active_graph/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activegraph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 10.0.0.pre.beta.
|
4
|
+
version: 10.0.0.pre.beta.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andreas Ronge, Brian Underwood, Chris Grigg, Heinrich Klobuczek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-04-
|
11
|
+
date: 2020-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -128,14 +128,14 @@ dependencies:
|
|
128
128
|
requirements:
|
129
129
|
- - ">="
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: 0.4.
|
131
|
+
version: 0.4.1
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: 0.4.
|
138
|
+
version: 0.4.1
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: os
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -262,6 +262,7 @@ files:
|
|
262
262
|
- lib/active_graph/core.rb
|
263
263
|
- lib/active_graph/core/connection_failed_error.rb
|
264
264
|
- lib/active_graph/core/cypher_error.rb
|
265
|
+
- lib/active_graph/core/entity.rb
|
265
266
|
- lib/active_graph/core/instrumentable.rb
|
266
267
|
- lib/active_graph/core/label.rb
|
267
268
|
- lib/active_graph/core/logging.rb
|
@@ -273,7 +274,6 @@ files:
|
|
273
274
|
- lib/active_graph/core/query_ext.rb
|
274
275
|
- lib/active_graph/core/query_find_in_batches.rb
|
275
276
|
- lib/active_graph/core/record.rb
|
276
|
-
- lib/active_graph/core/relationship.rb
|
277
277
|
- lib/active_graph/core/result.rb
|
278
278
|
- lib/active_graph/core/schema.rb
|
279
279
|
- lib/active_graph/core/schema_errors.rb
|
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'active_graph/core/wrappable'
|
2
|
-
|
3
|
-
module ActiveGraph
|
4
|
-
module Core
|
5
|
-
module Relationship
|
6
|
-
def props; properties; end
|
7
|
-
def neo_id; id; end
|
8
|
-
def start_node_neo_id; start_node_id; end
|
9
|
-
def end_node_neo_id; end_node_id; end
|
10
|
-
def rel_type; type; end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|