isomorfeus-data 1.0.0.zeta9 → 1.0.0.zeta10
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/lib/isomorfeus/data/attribute_support.rb +6 -1
- data/lib/isomorfeus/data/generic_class_api.rb +10 -1
- data/lib/isomorfeus/data/generic_instance_api.rb +4 -0
- data/lib/isomorfeus/data/version.rb +1 -1
- data/lib/isomorfeus_data/lucid_data/collection/mixin.rb +3 -1
- data/lib/isomorfeus_data/lucid_data/edge/mixin.rb +25 -32
- data/lib/isomorfeus_data/lucid_data/edge_collection/mixin.rb +32 -11
- data/lib/isomorfeus_data/lucid_data/graph/mixin.rb +1 -1
- data/lib/isomorfeus_data/lucid_data/node/mixin.rb +81 -41
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f806c11706bdf321a3522be0c3fbf727695d65b6c8b8f8897158c4d136e593b2
|
4
|
+
data.tar.gz: 462e6635a0c19080fba47e06bd076b15955e109c11b090175197e227e7c2d2db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10645fb7608b96f4f2b2e6a5a3d8f89de7d28ef1aef47920a4566b486a73ee4992a09c61b1290008d60b4129e0fa8d9b2acd7447bec4e4d0daba54d95da92686
|
7
|
+
data.tar.gz: 55e236b32fb9c8b1432ae7c18f5e16b1f50432e70d7e5691f8367ad1578aa8af84f570562d8484e7fb8a6b1e1c17ce4a9e93bbe0e8adee607e9ed30dbc8f00cb
|
@@ -37,7 +37,12 @@ module Isomorfeus
|
|
37
37
|
attribute_conditions[name] = options
|
38
38
|
|
39
39
|
define_method(name) do
|
40
|
-
_get_attribute(name)
|
40
|
+
v = _get_attribute(name)
|
41
|
+
%x{
|
42
|
+
if (v instanceof Object && !(v instanceof Array)) {
|
43
|
+
return Opal.Hash.$new(v);
|
44
|
+
} else { return v; }
|
45
|
+
}
|
41
46
|
end
|
42
47
|
|
43
48
|
define_method("#{name}=") do |val|
|
@@ -35,7 +35,7 @@ module Isomorfeus
|
|
35
35
|
|
36
36
|
def load(key:)
|
37
37
|
instance = self.new(key: key)
|
38
|
-
|
38
|
+
promise_load(key: key, instance: instance) unless instance.loaded?
|
39
39
|
instance
|
40
40
|
end
|
41
41
|
|
@@ -57,6 +57,15 @@ module Isomorfeus
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
+
def promise_load_once(key:, instance: nil)
|
61
|
+
instance = self.new(key: key) unless instance
|
62
|
+
if instance.loaded?
|
63
|
+
Promise.new.resolve(instance)
|
64
|
+
else
|
65
|
+
promise_load(key: key, instance: instance)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
60
69
|
def promise_query(props = {})
|
61
70
|
validate_props(props)
|
62
71
|
props_json = props.to_json
|
@@ -44,6 +44,14 @@ module LucidData
|
|
44
44
|
other_from if other_to == node
|
45
45
|
end
|
46
46
|
|
47
|
+
def from
|
48
|
+
graph&.node_from_sid(from_as_sid)
|
49
|
+
end
|
50
|
+
|
51
|
+
def to
|
52
|
+
graph&.node_from_sid(to_as_sid)
|
53
|
+
end
|
54
|
+
|
47
55
|
def to_transport
|
48
56
|
hash = { "attributes" => _get_selected_attributes,
|
49
57
|
"from" => from_as_sid,
|
@@ -119,44 +127,39 @@ module LucidData
|
|
119
127
|
@_changed_attributes[name] = val
|
120
128
|
end
|
121
129
|
|
122
|
-
def from
|
123
|
-
sid = from_as_sid
|
124
|
-
Isomorfeus.instance_from_sid(sid) if sid
|
125
|
-
end
|
126
|
-
|
127
130
|
def from_as_sid
|
128
131
|
@_changed_from ? @_changed_from : Redux.fetch_by_path(*@_from_path)
|
129
132
|
end
|
130
133
|
|
131
|
-
def from=(
|
134
|
+
def from=(node)
|
132
135
|
changed!
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
+
old_from = from
|
137
|
+
if node.respond_to?(:to_sid)
|
138
|
+
@_changed_from = node.to_sid
|
136
139
|
else
|
137
|
-
@_changed_from =
|
138
|
-
Isomorfeus.instance_from_sid(
|
140
|
+
@_changed_from = node
|
141
|
+
node = Isomorfeus.instance_from_sid(node)
|
139
142
|
end
|
140
|
-
|
141
|
-
|
142
|
-
def to
|
143
|
-
sid = to_as_sid
|
144
|
-
Isomorfeus.instance_from_sid(sid) if sid
|
143
|
+
@_collection.update_node_to_edge_cache(self, old_from, node) if @_collection
|
144
|
+
node
|
145
145
|
end
|
146
146
|
|
147
147
|
def to_as_sid
|
148
148
|
@_changed_to ? @_changed_to : Redux.fetch_by_path(*@_to_path)
|
149
149
|
end
|
150
150
|
|
151
|
-
def to=(
|
151
|
+
def to=(node)
|
152
152
|
changed!
|
153
|
-
|
154
|
-
|
155
|
-
|
153
|
+
old_to = to
|
154
|
+
if node.respond_to?(:to_sid)
|
155
|
+
@_changed_to = node.to_sid
|
156
|
+
node
|
156
157
|
else
|
157
|
-
@_changed_to =
|
158
|
-
Isomorfeus.instance_from_sid(
|
158
|
+
@_changed_to = node
|
159
|
+
node = Isomorfeus.instance_from_sid(node)
|
159
160
|
end
|
161
|
+
@_collection.update_node_to_edge_cache(self, old_to, node) if @_collection
|
162
|
+
node
|
160
163
|
end
|
161
164
|
else # RUBY_ENGINE
|
162
165
|
unless base == LucidData::Edge::Base || base == LucidData::Link::Base
|
@@ -225,11 +228,6 @@ module LucidData
|
|
225
228
|
@_raw_attributes[name] = val
|
226
229
|
end
|
227
230
|
|
228
|
-
def from
|
229
|
-
sid = @_changed_from ? @_changed_from : @_raw_from
|
230
|
-
graph&.node_from_sid(sid)
|
231
|
-
end
|
232
|
-
|
233
231
|
def from_as_sid
|
234
232
|
@_changed_from ? @_changed_from : @_raw_from
|
235
233
|
end
|
@@ -250,11 +248,6 @@ module LucidData
|
|
250
248
|
node
|
251
249
|
end
|
252
250
|
|
253
|
-
def to
|
254
|
-
sid = @_changed_to ? @_changed_to : @_raw_to
|
255
|
-
graph&.node_from_sid(sid)
|
256
|
-
end
|
257
|
-
|
258
251
|
def to_as_sid
|
259
252
|
@_changed_to ? @_changed_to : @_raw_to
|
260
253
|
end
|
@@ -49,6 +49,7 @@ module LucidData
|
|
49
49
|
else
|
50
50
|
sid = arg
|
51
51
|
edge = Isomorfeus.instance_from_sid(sid)
|
52
|
+
edge.collection = self
|
52
53
|
end
|
53
54
|
[edge, sid]
|
54
55
|
end
|
@@ -79,6 +80,16 @@ module LucidData
|
|
79
80
|
@_changed = true
|
80
81
|
end
|
81
82
|
|
83
|
+
def update_node_to_edge_cache(edge, old_node, new_node)
|
84
|
+
old_node_sid = old_node.to_sid
|
85
|
+
new_node_sid = new_node.to_sid
|
86
|
+
edge_sid = edge.to_sid
|
87
|
+
if @_node_to_edge_cache.key?(old_node_sid)
|
88
|
+
@_node_to_edge_cache[old_node_sid].delete_if { |node_edge| node_edge.to_sid == edge_sid }
|
89
|
+
end
|
90
|
+
@_node_to_edge_cache[new_node_sid].push(edge) if @_node_to_edge_cache.key?(new_node_sid)
|
91
|
+
end
|
92
|
+
|
82
93
|
def to_transport
|
83
94
|
hash = { 'attributes' => _get_selected_attributes, 'edges' => edges_as_sids }
|
84
95
|
hash.merge!('revision' => revision) if revision
|
@@ -103,6 +114,7 @@ module LucidData
|
|
103
114
|
@_revision = revision ? revision : Redux.fetch_by_path(:data_state, @class_name, @key, :revision)
|
104
115
|
@_graph = graph
|
105
116
|
@_composition = composition
|
117
|
+
@_node_to_edge_cache = {}
|
106
118
|
@_changed_collection = nil
|
107
119
|
@_edge_con = self.class.edge_conditions
|
108
120
|
@_validate_edges = @_edge_con ? true : false
|
@@ -162,6 +174,23 @@ module LucidData
|
|
162
174
|
[]
|
163
175
|
end
|
164
176
|
|
177
|
+
def edges_for_node(node)
|
178
|
+
node_sid = node.respond_to?(:to_sid) ? node.to_sid : node
|
179
|
+
return @_node_to_edge_cache[node_sid] if @_node_to_edge_cache.key?(node_sid)
|
180
|
+
node_edge_sids = edges_as_sids.select do |edge_sid|
|
181
|
+
edge_data = Redux.fetch_by_path(:data_state, edge_sid[0], edge_sid[1])
|
182
|
+
(edge_data.JS[:from] == node_sid || edge_data.JS[:to] == node_sid) ? true : false
|
183
|
+
end
|
184
|
+
node_edges = node_edge_sids.map do |edge_sid|
|
185
|
+
edge = Isomorfeus.instance_from_sid(edge_sid)
|
186
|
+
edge.collection = self
|
187
|
+
edge
|
188
|
+
end
|
189
|
+
@_node_to_edge_cache[node_sid] = node_edges
|
190
|
+
end
|
191
|
+
alias edges_for_vertex edges_for_node
|
192
|
+
alias edges_for_document edges_for_node
|
193
|
+
|
165
194
|
def each(&block)
|
166
195
|
edges.each(&block)
|
167
196
|
end
|
@@ -190,7 +219,9 @@ module LucidData
|
|
190
219
|
|
191
220
|
def [](idx)
|
192
221
|
sid = edges_as_sids[idx]
|
193
|
-
Isomorfeus.instance_from_sid(sid)
|
222
|
+
edge = Isomorfeus.instance_from_sid(sid)
|
223
|
+
edge.collection = self
|
224
|
+
edge
|
194
225
|
end
|
195
226
|
|
196
227
|
def []=(idx, edge)
|
@@ -488,16 +519,6 @@ module LucidData
|
|
488
519
|
alias edges_for_vertex edges_for_node
|
489
520
|
alias edges_for_document edges_for_node
|
490
521
|
|
491
|
-
def update_node_to_edge_cache(edge, old_node, new_node)
|
492
|
-
old_node_sid = old_node.to_sid
|
493
|
-
new_node_sid = new_node.to_sid
|
494
|
-
edge_sid = edge.to_sid
|
495
|
-
if @_node_to_edge_cache.key?(old_node_sid)
|
496
|
-
@_node_to_edge_cache[old_node_sid].delete_if { |node_edge| node_edge.to_sid == edge_sid }
|
497
|
-
end
|
498
|
-
@_node_to_edge_cache[new_node_sid].push(edge) if @_node_to_edge_cache.key?(new_node_sid)
|
499
|
-
end
|
500
|
-
|
501
522
|
def each(&block)
|
502
523
|
@_raw_collection.each(&block)
|
503
524
|
end
|
@@ -289,7 +289,7 @@ module LucidData
|
|
289
289
|
end
|
290
290
|
|
291
291
|
def _init_edge_collections
|
292
|
-
keys = self.class.
|
292
|
+
keys = self.class.edge_collections.keys
|
293
293
|
keys << :edges if keys.empty?
|
294
294
|
keys.each do |access_name|
|
295
295
|
sid = Redux.fetch_by_path(*(@_edges_path + [access_name]))
|
@@ -45,47 +45,6 @@ module LucidData
|
|
45
45
|
graph&.linked_nodes_for_node(self)
|
46
46
|
end
|
47
47
|
|
48
|
-
def method_missing(method_name, *args, &block)
|
49
|
-
if graph
|
50
|
-
method_name_s = method_name.to_s
|
51
|
-
singular_name = method_name_s.singularize
|
52
|
-
plural_name = method_name_s.pluralize
|
53
|
-
node_edges = edges
|
54
|
-
if method_name_s == plural_name
|
55
|
-
# return all nodes
|
56
|
-
nodes = []
|
57
|
-
sid = to_sid
|
58
|
-
node_edges.each do |edge|
|
59
|
-
from_sid = edge.from_as_sid
|
60
|
-
to_sid = edge.to_as_sid
|
61
|
-
node = if from_sid[0].underscore == singular_name && to_sid == sid
|
62
|
-
edge.from
|
63
|
-
elsif to_sid[0].underscore == singular_name && from_sid == sid
|
64
|
-
edge.to
|
65
|
-
end
|
66
|
-
nodes << node if node
|
67
|
-
end
|
68
|
-
return nodes
|
69
|
-
elsif method_name_s == singular_name
|
70
|
-
# return one node
|
71
|
-
sid = to_sid
|
72
|
-
node_edges.each do |edge|
|
73
|
-
from_sid = edge.from_as_sid
|
74
|
-
to_sid = edge.to_as_sid
|
75
|
-
node = if from_sid[0].underscore == singular_name && to_sid == sid
|
76
|
-
edge.from
|
77
|
-
elsif to_sid[0].underscore == singular_name && from_sid == sid
|
78
|
-
edge.to
|
79
|
-
end
|
80
|
-
return node if node
|
81
|
-
end
|
82
|
-
nil
|
83
|
-
end
|
84
|
-
else
|
85
|
-
super(method_name, *args, &block)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
48
|
def to_transport
|
90
49
|
hash = _get_selected_attributes
|
91
50
|
hash.merge!("revision" => revision) if revision
|
@@ -138,6 +97,46 @@ module LucidData
|
|
138
97
|
changed!
|
139
98
|
@_changed_attributes[name] = val
|
140
99
|
end
|
100
|
+
|
101
|
+
def method_missing(method_name, *args, &block)
|
102
|
+
if graph
|
103
|
+
singular_name = `method_name.endsWith('s')` ? method_name.singularize : method_name
|
104
|
+
node_edges = edges
|
105
|
+
sid = to_sid
|
106
|
+
camelized_singular = singular_name.camelize
|
107
|
+
|
108
|
+
if method_name == singular_name
|
109
|
+
# return one node
|
110
|
+
node_edges.each do |edge|
|
111
|
+
from_sid = edge.from_as_sid
|
112
|
+
to_sid = edge.to_as_sid
|
113
|
+
node = if from_sid[0] == camelized_singular && to_sid == sid
|
114
|
+
edge.from
|
115
|
+
elsif to_sid[0] == camelized_singular && from_sid == sid
|
116
|
+
edge.to
|
117
|
+
end
|
118
|
+
return node if node
|
119
|
+
end
|
120
|
+
nil
|
121
|
+
elsif method_name == method_name.pluralize
|
122
|
+
# return all nodes
|
123
|
+
nodes = []
|
124
|
+
node_edges.each do |edge|
|
125
|
+
from_sid = edge.from_as_sid
|
126
|
+
to_sid = edge.to_as_sid
|
127
|
+
node = if from_sid[0] == camelized_singular && to_sid == sid
|
128
|
+
edge.from
|
129
|
+
elsif to_sid[0] == camelized_singular && from_sid == sid
|
130
|
+
edge.to
|
131
|
+
end
|
132
|
+
nodes << node if node
|
133
|
+
end
|
134
|
+
return nodes
|
135
|
+
end
|
136
|
+
else
|
137
|
+
super(method_name, *args, &block)
|
138
|
+
end
|
139
|
+
end
|
141
140
|
else # RUBY_ENGINE
|
142
141
|
unless base == LucidData::Node::Base || base == LucidData::Document::Base || base == LucidData::Vertex::Base
|
143
142
|
Isomorfeus.add_valid_data_class(base)
|
@@ -185,6 +184,47 @@ module LucidData
|
|
185
184
|
changed!
|
186
185
|
@_raw_attributes[name] = val
|
187
186
|
end
|
187
|
+
|
188
|
+
def method_missing(method_name, *args, &block)
|
189
|
+
if graph
|
190
|
+
method_name_s = method_name.to_s
|
191
|
+
singular_name = method_name_s.singularize
|
192
|
+
node_edges = edges
|
193
|
+
sid = to_sid
|
194
|
+
camelized_singular = singular_name.camelize
|
195
|
+
|
196
|
+
if method_name_s == singular_name
|
197
|
+
# return one node
|
198
|
+
node_edges.each do |edge|
|
199
|
+
from_sid = edge.from_as_sid
|
200
|
+
to_sid = edge.to_as_sid
|
201
|
+
node = if from_sid[0] == camelized_singular && to_sid == sid
|
202
|
+
edge.from
|
203
|
+
elsif to_sid[0] == camelized_singular && from_sid == sid
|
204
|
+
edge.to
|
205
|
+
end
|
206
|
+
return node if node
|
207
|
+
end
|
208
|
+
nil
|
209
|
+
elsif method_name_s == method_name_s.pluralize
|
210
|
+
# return all nodes
|
211
|
+
nodes = []
|
212
|
+
node_edges.each do |edge|
|
213
|
+
from_sid = edge.from_as_sid
|
214
|
+
to_sid = edge.to_as_sid
|
215
|
+
node = if from_sid[0] == camelized_singular && to_sid == sid
|
216
|
+
edge.from
|
217
|
+
elsif to_sid[0] == camelized_singular && from_sid == sid
|
218
|
+
edge.to
|
219
|
+
end
|
220
|
+
nodes << node if node
|
221
|
+
end
|
222
|
+
return nodes
|
223
|
+
end
|
224
|
+
else
|
225
|
+
super(method_name, *args, &block)
|
226
|
+
end
|
227
|
+
end
|
188
228
|
end # RUBY_ENGINE
|
189
229
|
end
|
190
230
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: isomorfeus-data
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.zeta10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Biedermann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-12-
|
11
|
+
date: 2019-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 16.12.
|
89
|
+
version: 16.12.4
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 16.12.
|
96
|
+
version: 16.12.4
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: isomorfeus-redux
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,28 +114,28 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - '='
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 1.0.0.
|
117
|
+
version: 1.0.0.zeta10
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - '='
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 1.0.0.
|
124
|
+
version: 1.0.0.zeta10
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: isomorfeus
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - '='
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: 1.0.0.
|
131
|
+
version: 1.0.0.zeta10
|
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: 1.0.0.
|
138
|
+
version: 1.0.0.zeta10
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: opal-webpack-loader
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|