isomorfeus-data 1.0.0.zeta12 → 1.0.0.zeta13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/lib/isomorfeus-data.rb +2 -0
- data/lib/isomorfeus/data/attribute_support.rb +2 -2
- data/lib/isomorfeus/data/config.rb +1 -1
- data/lib/isomorfeus/data/element_validator.rb +16 -16
- data/lib/isomorfeus/data/generic_class_api.rb +34 -52
- data/lib/isomorfeus/data/generic_instance_api.rb +35 -8
- data/lib/isomorfeus/data/handler/arango.rb +2 -3
- data/lib/isomorfeus/data/handler/generic.rb +44 -55
- data/lib/isomorfeus/data/handler/object_call.rb +2 -3
- data/lib/isomorfeus/data/handler/object_store.rb +2 -3
- data/lib/isomorfeus/data/version.rb +1 -1
- data/lib/isomorfeus_data/lucid_data/array/base.rb +0 -2
- data/lib/isomorfeus_data/lucid_data/array/mixin.rb +18 -22
- data/lib/isomorfeus_data/lucid_data/collection/base.rb +0 -2
- data/lib/isomorfeus_data/lucid_data/collection/mixin.rb +33 -36
- data/lib/isomorfeus_data/lucid_data/composition/base.rb +0 -2
- data/lib/isomorfeus_data/lucid_data/composition/mixin.rb +35 -29
- data/lib/isomorfeus_data/lucid_data/document/base.rb +0 -2
- data/lib/isomorfeus_data/lucid_data/edge/base.rb +0 -2
- data/lib/isomorfeus_data/lucid_data/edge/mixin.rb +39 -31
- data/lib/isomorfeus_data/lucid_data/edge_collection/base.rb +0 -2
- data/lib/isomorfeus_data/lucid_data/edge_collection/mixin.rb +33 -29
- data/lib/isomorfeus_data/lucid_data/graph/base.rb +0 -2
- data/lib/isomorfeus_data/lucid_data/graph/mixin.rb +41 -40
- data/lib/isomorfeus_data/lucid_data/hash/base.rb +0 -2
- data/lib/isomorfeus_data/lucid_data/hash/mixin.rb +20 -25
- data/lib/isomorfeus_data/lucid_data/link/base.rb +0 -2
- data/lib/isomorfeus_data/lucid_data/link_collection/base.rb +0 -2
- data/lib/isomorfeus_data/lucid_data/node/base.rb +0 -2
- data/lib/isomorfeus_data/lucid_data/node/mixin.rb +18 -23
- data/lib/isomorfeus_data/lucid_data/query/base.rb +13 -0
- data/lib/isomorfeus_data/lucid_data/query/mixin.rb +88 -0
- data/lib/isomorfeus_data/lucid_data/query_result.rb +12 -10
- data/lib/isomorfeus_data/lucid_data/vertex/base.rb +0 -2
- data/lib/lucid_arango/collection/base.rb +0 -2
- data/lib/lucid_arango/collection/mixin.rb +0 -2
- data/lib/lucid_arango/document/base.rb +0 -2
- data/lib/lucid_arango/edge/base.rb +0 -3
- data/lib/lucid_arango/edge/mixin.rb +0 -2
- data/lib/lucid_arango/edge_collection/base.rb +0 -2
- data/lib/lucid_arango/edge_collection/mixin.rb +0 -2
- data/lib/lucid_arango/graph/base.rb +0 -2
- data/lib/lucid_arango/graph/mixin.rb +0 -2
- data/lib/lucid_arango/node/base.rb +0 -3
- data/lib/lucid_arango/node/mixin.rb +0 -2
- data/lib/lucid_arango/object/base.rb +0 -2
- data/lib/lucid_arango/object/mixin.rb +1 -3
- data/lib/lucid_arango/remote_object/base.rb +0 -2
- data/lib/lucid_arango/remote_object/mixin.rb +0 -2
- data/lib/lucid_arango/vertex/base.rb +0 -2
- metadata +10 -8
@@ -3,7 +3,6 @@ module LucidData
|
|
3
3
|
module Mixin
|
4
4
|
def self.included(base)
|
5
5
|
base.include(Enumerable)
|
6
|
-
base.extend(LucidPropDeclaration::Mixin)
|
7
6
|
base.include(Isomorfeus::Data::AttributeSupport)
|
8
7
|
base.extend(Isomorfeus::Data::GenericClassApi)
|
9
8
|
base.include(Isomorfeus::Data::GenericInstanceApi)
|
@@ -101,7 +100,9 @@ module LucidData
|
|
101
100
|
def to_transport
|
102
101
|
hash = { 'attributes' => _get_selected_attributes, 'edges' => edges_as_sids }
|
103
102
|
hash.merge!('revision' => revision) if revision
|
104
|
-
{ @class_name => { @key => hash }}
|
103
|
+
result = { @class_name => { @key => hash }}
|
104
|
+
result.deep_merge!(@class_name => { @previous_key => { new_key: @key}}) if @previous_key
|
105
|
+
result
|
105
106
|
end
|
106
107
|
|
107
108
|
def included_items_to_transport
|
@@ -117,8 +118,7 @@ module LucidData
|
|
117
118
|
@key = key.to_s
|
118
119
|
@class_name = self.class.name
|
119
120
|
@class_name = @class_name.split('>::').last if @class_name.start_with?('#<')
|
120
|
-
|
121
|
-
@_edges_path = [:data_state, @class_name, @key, :edges]
|
121
|
+
_update_paths
|
122
122
|
@_revision = revision ? revision : Redux.fetch_by_path(:data_state, @class_name, @key, :revision)
|
123
123
|
@_graph = graph
|
124
124
|
@_composition = composition
|
@@ -163,6 +163,11 @@ module LucidData
|
|
163
163
|
@_changed_collection = nil
|
164
164
|
end
|
165
165
|
|
166
|
+
def _update_paths
|
167
|
+
@_store_path = [:data_state, @class_name, @key, :attributes]
|
168
|
+
@_edges_path = [:data_state, @class_name, @key, :edges]
|
169
|
+
end
|
170
|
+
|
166
171
|
def edges
|
167
172
|
edges_as_sids.map do |edge_sid|
|
168
173
|
edge = Isomorfeus.instance_from_sid(edge_sid)
|
@@ -459,33 +464,28 @@ module LucidData
|
|
459
464
|
end
|
460
465
|
alias prepend unshift
|
461
466
|
else # RUBY_ENGINE
|
462
|
-
unless base == LucidData::EdgeCollection::Base || base == LucidData::LinkCollection::Base
|
463
|
-
Isomorfeus.add_valid_data_class(base)
|
464
|
-
base.prop :pub_sub_client, default: nil
|
465
|
-
base.prop :current_user, default: Anonymous.new
|
466
|
-
end
|
467
|
+
Isomorfeus.add_valid_data_class(base) unless base == LucidData::EdgeCollection::Base || base == LucidData::LinkCollection::Base
|
467
468
|
|
468
469
|
base.instance_exec do
|
469
|
-
def
|
470
|
-
|
471
|
-
revision =
|
472
|
-
attributes =
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
self.new(key: key, revision: revision, attributes: attributes, edges: edges, links: links)
|
470
|
+
def instance_from_transport(instance_data, included_items_data)
|
471
|
+
key = instance_data[self.name].keys.first
|
472
|
+
revision = instance_data[self.name][key].key?('revision') ? instance_data[self.name][key]['revision'] : nil
|
473
|
+
attributes = instance_data[self.name][key].key?('attributes') ? instance_data[self.name][key]['attributes'] : nil
|
474
|
+
edges_sids = instance_data[self.name][key].key?('edges') ? instance_data[self.name][key]['edges'] : []
|
475
|
+
edges = []
|
476
|
+
edges_sids.each do |sid|
|
477
|
+
edge_class_name = sid[0]
|
478
|
+
edge_key = sid[1]
|
479
|
+
Isomorfeus.raise_error "#{self.name}: #{edge_class_name}: Not a valid LucidData class!" unless Isomorfeus.valid_data_class_name?(edge_class_name)
|
480
|
+
if included_items_data.key?(edge_class_name) && included_items_data[edge_class_name].key?(edge_key)
|
481
|
+
edge_class = Isomorfeus.cached_data_class(edge_class_name)
|
482
|
+
Isomorfeus.raise_error "#{self.name}: #{edge_class_name}: Cannot get class!" unless edge_class
|
483
|
+
edge = edge_class.instance_from_transport({ edge_class_name => { edge_key => included_items_data[edge_class_name][edge_key] }}, included_items_data)
|
484
|
+
Isomorfeus.raise_error "#{self.name}: #{edge_class_name} with key #{edge_key} could not be extracted from transport data!" unless edge
|
485
|
+
edges << edge
|
486
|
+
end
|
487
|
+
end
|
488
|
+
new(key: key, revision: revision, attributes: attributes, edges: edges)
|
489
489
|
end
|
490
490
|
end
|
491
491
|
|
@@ -512,6 +512,10 @@ module LucidData
|
|
512
512
|
@_raw_collection = edges
|
513
513
|
end
|
514
514
|
|
515
|
+
def _unchange!
|
516
|
+
@changed = false
|
517
|
+
end
|
518
|
+
|
515
519
|
def edges
|
516
520
|
@_raw_collection
|
517
521
|
end
|
@@ -3,7 +3,6 @@ module LucidData
|
|
3
3
|
module Mixin
|
4
4
|
def self.included(base)
|
5
5
|
base.include(Enumerable)
|
6
|
-
base.extend(LucidPropDeclaration::Mixin)
|
7
6
|
base.include(Isomorfeus::Data::AttributeSupport)
|
8
7
|
base.extend(Isomorfeus::Data::GenericClassApi)
|
9
8
|
base.include(Isomorfeus::Data::GenericInstanceApi)
|
@@ -55,7 +54,7 @@ module LucidData
|
|
55
54
|
|
56
55
|
def _validate_node_collection(access_name, collection)
|
57
56
|
unless node_collections.key?(access_name) || access_name == :nodes
|
58
|
-
|
57
|
+
Isomorfeus.raise_error(message: "#{self.name}: No such node collection declared: '#{access_name}'!")
|
59
58
|
end
|
60
59
|
Isomorfeus::Data::ElementValidator.new(self.name, collection, node_collections[access_name]).validate! if node_collections[access_name]
|
61
60
|
end
|
@@ -95,7 +94,7 @@ module LucidData
|
|
95
94
|
|
96
95
|
def _validate_edge_collection(access_name, collection)
|
97
96
|
unless edge_collections.key?(access_name) || access_name == :edges
|
98
|
-
|
97
|
+
Isomorfeus.raise_error(message: "#{self.name}: No such edge collection declared: '#{access_name}'!")
|
99
98
|
end
|
100
99
|
Isomorfeus::Data::ElementValidator.new(self.name, collection, edge_collections[access_name]).validate! if edge_collections[access_name]
|
101
100
|
end
|
@@ -223,7 +222,9 @@ module LucidData
|
|
223
222
|
hash['edges'][name.to_s] = collection.to_sid if collection
|
224
223
|
end
|
225
224
|
hash.merge!('revision' => revision) if revision
|
226
|
-
{ @class_name => { @key => hash }}
|
225
|
+
result = { @class_name => { @key => hash }}
|
226
|
+
result.deep_merge!(@class_name => { @previous_key => { new_key: @key}}) if @previous_key
|
227
|
+
result
|
227
228
|
end
|
228
229
|
|
229
230
|
def included_items_to_transport
|
@@ -248,9 +249,7 @@ module LucidData
|
|
248
249
|
@key = key.to_s
|
249
250
|
@class_name = self.class.name
|
250
251
|
@class_name = @class_name.split('>::').last if @class_name.start_with?('#<')
|
251
|
-
|
252
|
-
@_edges_path = [:data_state, @class_name, @key, :edges]
|
253
|
-
@_nodes_path = [:data_state, @class_name, @key, :nodes]
|
252
|
+
_update_paths
|
254
253
|
@_revision = revision ? revision : Redux.fetch_by_path(:data_state, @class_name, @key, :revision)
|
255
254
|
@_composition = composition
|
256
255
|
@_changed = false
|
@@ -368,6 +367,12 @@ module LucidData
|
|
368
367
|
nil
|
369
368
|
end
|
370
369
|
|
370
|
+
def _update_paths
|
371
|
+
@_store_path = [:data_state, @class_name, @key, :attributes]
|
372
|
+
@_edges_path = [:data_state, @class_name, @key, :edges]
|
373
|
+
@_nodes_path = [:data_state, @class_name, @key, :nodes]
|
374
|
+
end
|
375
|
+
|
371
376
|
def edge_collections
|
372
377
|
_init_edge_collections if @_edge_collections.empty?
|
373
378
|
@_edge_collections
|
@@ -381,42 +386,34 @@ module LucidData
|
|
381
386
|
alias document_collections node_collections
|
382
387
|
alias vertex_collections node_collections
|
383
388
|
else # RUBY_ENGINE
|
384
|
-
unless base == LucidData::Graph::Base
|
385
|
-
Isomorfeus.add_valid_data_class(base)
|
386
|
-
base.prop :pub_sub_client, default: nil
|
387
|
-
base.prop :current_user, default: Anonymous.new
|
388
|
-
end
|
389
|
+
Isomorfeus.add_valid_data_class(base) unless base == LucidData::Graph::Base
|
389
390
|
|
390
391
|
base.instance_exec do
|
391
|
-
def
|
392
|
-
|
393
|
-
revision =
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
self.
|
398
|
-
|
392
|
+
def instance_from_transport(instance_data, included_items_data)
|
393
|
+
key = instance_data[self.name].keys.first
|
394
|
+
revision = instance_data[self.name][key].key?('revision') ? instance_data[self.name][key]['revision'] : nil
|
395
|
+
attributes = instance_data[self.name][key].key?('attributes') ? instance_data[self.name][key]['attributes'] : nil
|
396
|
+
|
397
|
+
nodes_sids = instance_data[self.name][key].key?('nodes') ? instance_data[self.name][key]['nodes'] : []
|
398
|
+
edges_sids = instance_data[self.name][key].key?('edges') ? instance_data[self.name][key]['edges'] : []
|
399
|
+
|
400
|
+
nodes_edges = [[],[]]
|
401
|
+
[nodes_sids, edges_sids].each_with_index do |sids, nodes_edges_index|
|
402
|
+
sids.each do |sid|
|
403
|
+
node_class_name = sid[0]
|
404
|
+
node_key = sid[1]
|
405
|
+
Isomorfeus.raise_error "#{self.name}: #{node_class_name}: Not a valid LucidData class!" unless Isomorfeus.valid_data_class_name?(node_class_name)
|
406
|
+
if included_items_data.key?(node_class_name) && included_items_data[node_class_name].key?(node_key)
|
407
|
+
node_class = Isomorfeus.cached_data_class(node_class_name)
|
408
|
+
Isomorfeus.raise_error "#{self.name}: #{node_class_name}: Cannot get class!" unless node_class
|
409
|
+
node = node_class.instance_from_transport({ node_class_name => { node_key => included_items_data[node_class_name][node_key] }}, included_items_data)
|
410
|
+
Isomorfeus.raise_error "#{self.name}: #{node_class_name} with key #{node_key} could not be extracted from transport data!" unless node
|
411
|
+
nodes_edges[nodes_edges_index] << node
|
412
|
+
end
|
413
|
+
end
|
414
|
+
end
|
399
415
|
|
400
|
-
|
401
|
-
pub_sub_client: nil, current_user: nil)
|
402
|
-
attributes = {} unless attributes
|
403
|
-
val_edges = edges || links
|
404
|
-
val_nodes = documents || nodes || vertexes || vertices
|
405
|
-
_validate_attributes(attributes) if attributes.any?
|
406
|
-
_validate_edges(val_edges)
|
407
|
-
_validate_nodes(val_nodes)
|
408
|
-
data = instance_exec(key: key, revision: revision, parts: parts, attributes: attributes,
|
409
|
-
pub_sub_client: pub_sub_client, current_user: current_user, &@_save_block)
|
410
|
-
revision = data.delete(:revision)
|
411
|
-
attributes = data.delete(:attributes)
|
412
|
-
documents = data.delete(:documents)
|
413
|
-
vertexes = data.delete(:vertexes)
|
414
|
-
vertices = data.delete(:vertices)
|
415
|
-
nodes = data.delete(:nodes)
|
416
|
-
edges = data.delete(:edges)
|
417
|
-
links = data.delete(:links)
|
418
|
-
self.new(key: key, revision: revision, attributes: attributes, edges: edges, links: links, nodes: nodes, documents: documents,
|
419
|
-
vertices: vertices, vertexes: vertexes, pub_sub_client: nil, current_user: nil)
|
416
|
+
new(key: key, revision: revision, attributes: attributes, nodes: nodes_edges[0], edges: nodes_edges[1])
|
420
417
|
end
|
421
418
|
end
|
422
419
|
|
@@ -467,6 +464,10 @@ module LucidData
|
|
467
464
|
end
|
468
465
|
end
|
469
466
|
|
467
|
+
def _unchange!
|
468
|
+
@_changed = false
|
469
|
+
end
|
470
|
+
|
470
471
|
def edge_collections
|
471
472
|
@_edge_collections
|
472
473
|
end
|
@@ -3,7 +3,6 @@ module LucidData
|
|
3
3
|
module Mixin
|
4
4
|
def self.included(base)
|
5
5
|
base.include(Enumerable)
|
6
|
-
base.extend(LucidPropDeclaration::Mixin)
|
7
6
|
base.include(Isomorfeus::Data::AttributeSupport)
|
8
7
|
base.extend(Isomorfeus::Data::GenericClassApi)
|
9
8
|
base.include(Isomorfeus::Data::GenericInstanceApi)
|
@@ -26,7 +25,7 @@ module LucidData
|
|
26
25
|
def _relaxed_validate_attributes(attrs)
|
27
26
|
attribute_conditions.each_key do |attr|
|
28
27
|
if attribute_conditions[attr].key?(:required) && attribute_conditions[attr][:required] && !attrs.key?(attr)
|
29
|
-
|
28
|
+
Isomorfeus.raise_error(message: "Required attribute #{attr} not given!")
|
30
29
|
end
|
31
30
|
end
|
32
31
|
attrs.each { |attr, val| _relaxed_validate_attribute(attr, val) } if attribute_conditions.any?
|
@@ -49,7 +48,9 @@ module LucidData
|
|
49
48
|
def to_transport
|
50
49
|
hash = { 'attributes' => to_h }
|
51
50
|
hash['revision'] = revision if revision
|
52
|
-
{ @class_name => { @key => hash }}
|
51
|
+
result = { @class_name => { @key => hash }}
|
52
|
+
result.deep_merge!(@class_name => { @previous_key => { new_key: @key}}) if @previous_key
|
53
|
+
result
|
53
54
|
end
|
54
55
|
|
55
56
|
def _relaxed_validate_attribute(attr_name, attr_val)
|
@@ -89,7 +90,7 @@ module LucidData
|
|
89
90
|
@key = key.to_s
|
90
91
|
@class_name = self.class.name
|
91
92
|
@class_name = @class_name.split('>::').last if @class_name.start_with?('#<')
|
92
|
-
|
93
|
+
_update_paths
|
93
94
|
@_revision = revision ? revision : Redux.fetch_by_path(:data_state, @class_name, @key, :revision)
|
94
95
|
@_changed = false
|
95
96
|
@_changed_attributes = {}
|
@@ -125,6 +126,10 @@ module LucidData
|
|
125
126
|
@_changed_attributes = {}
|
126
127
|
end
|
127
128
|
|
129
|
+
def _update_paths
|
130
|
+
@_store_path = [:data_state, @class_name, @key, :attributes]
|
131
|
+
end
|
132
|
+
|
128
133
|
def changed?
|
129
134
|
@_changed || @_changed_attributes.any?
|
130
135
|
end
|
@@ -188,7 +193,7 @@ module LucidData
|
|
188
193
|
end
|
189
194
|
|
190
195
|
def key?(name)
|
191
|
-
_get_attribute(
|
196
|
+
_get_attribute(name) ? true : false
|
192
197
|
end
|
193
198
|
alias has_key? key?
|
194
199
|
|
@@ -262,11 +267,7 @@ module LucidData
|
|
262
267
|
self
|
263
268
|
end
|
264
269
|
else # RUBY_ENGINE
|
265
|
-
unless base == LucidData::Hash::Base
|
266
|
-
Isomorfeus.add_valid_data_class(base)
|
267
|
-
base.prop :pub_sub_client, default: nil
|
268
|
-
base.prop :current_user, default: Anonymous.new
|
269
|
-
end
|
270
|
+
Isomorfeus.add_valid_data_class(base) unless base == LucidData::Hash::Base
|
270
271
|
|
271
272
|
base.instance_exec do
|
272
273
|
def attribute(name, options = {})
|
@@ -283,21 +284,11 @@ module LucidData
|
|
283
284
|
end
|
284
285
|
end
|
285
286
|
|
286
|
-
def
|
287
|
-
|
288
|
-
revision =
|
289
|
-
attributes =
|
290
|
-
|
291
|
-
end
|
292
|
-
|
293
|
-
def save(key:, revision: nil, attributes: nil, pub_sub_client: nil, current_user: nil)
|
294
|
-
attributes = {} unless attributes
|
295
|
-
_relaxed_validate_attributes(attributes)
|
296
|
-
data = instance_exec(key: key, revision: revision, attributes: attributes,
|
297
|
-
pub_sub_client: pub_sub_client, current_user: current_user, &@_save_block)
|
298
|
-
revision = data.delete(:revision)
|
299
|
-
attributes = data.delete(:attributes)
|
300
|
-
self.new(key: key, revision: revision, attributes: attributes)
|
287
|
+
def instance_from_transport(instance_data, _included_items_data)
|
288
|
+
key = instance_data[self.name].keys.first
|
289
|
+
revision = instance_data[self.name][key].key?('revision') ? instance_data[self.name][key]['revision'] : nil
|
290
|
+
attributes = instance_data[self.name][key].key?('attributes') ? instance_data[self.name][key]['attributes'] : nil
|
291
|
+
new(key: key, revision: revision, attributes: attributes)
|
301
292
|
end
|
302
293
|
end
|
303
294
|
|
@@ -314,6 +305,10 @@ module LucidData
|
|
314
305
|
@_raw_attributes = attributes
|
315
306
|
end
|
316
307
|
|
308
|
+
def _unchange!
|
309
|
+
@_changed = false
|
310
|
+
end
|
311
|
+
|
317
312
|
def changed?
|
318
313
|
@_changed
|
319
314
|
end
|
@@ -2,7 +2,6 @@ module LucidData
|
|
2
2
|
module Node
|
3
3
|
module Mixin
|
4
4
|
def self.included(base)
|
5
|
-
base.extend(LucidPropDeclaration::Mixin)
|
6
5
|
base.include(Isomorfeus::Data::AttributeSupport)
|
7
6
|
base.extend(Isomorfeus::Data::GenericClassApi)
|
8
7
|
base.include(Isomorfeus::Data::GenericInstanceApi)
|
@@ -48,7 +47,9 @@ module LucidData
|
|
48
47
|
def to_transport
|
49
48
|
hash = _get_selected_attributes
|
50
49
|
hash.merge!("revision" => revision) if revision
|
51
|
-
{ @class_name => { @key => hash }}
|
50
|
+
result = { @class_name => { @key => hash }}
|
51
|
+
result.deep_merge!(@class_name => { @previous_key => { new_key: @key}}) if @previous_key
|
52
|
+
result
|
52
53
|
end
|
53
54
|
|
54
55
|
if RUBY_ENGINE == 'opal'
|
@@ -56,7 +57,7 @@ module LucidData
|
|
56
57
|
@key = key.to_s
|
57
58
|
@class_name = self.class.name
|
58
59
|
@class_name = @class_name.split('>::').last if @class_name.start_with?('#<')
|
59
|
-
|
60
|
+
_update_paths
|
60
61
|
@_revision = revision ? revision : Redux.fetch_by_path(:data_state, :revision, @class_name, @key)
|
61
62
|
@_collection = collection
|
62
63
|
@_composition = composition
|
@@ -84,6 +85,10 @@ module LucidData
|
|
84
85
|
@_changed = false
|
85
86
|
end
|
86
87
|
|
88
|
+
def _update_paths
|
89
|
+
@_store_path = [:data_state, @class_name, @key]
|
90
|
+
end
|
91
|
+
|
87
92
|
def each(&block)
|
88
93
|
_get_attributes.each(&block)
|
89
94
|
end
|
@@ -138,28 +143,14 @@ module LucidData
|
|
138
143
|
end
|
139
144
|
end
|
140
145
|
else # RUBY_ENGINE
|
141
|
-
unless base == LucidData::Node::Base || base == LucidData::Document::Base || base == LucidData::Vertex::Base
|
142
|
-
Isomorfeus.add_valid_data_class(base)
|
143
|
-
base.prop :pub_sub_client, default: nil
|
144
|
-
base.prop :current_user, default: Anonymous.new
|
145
|
-
end
|
146
|
+
Isomorfeus.add_valid_data_class(base) unless base == LucidData::Node::Base || base == LucidData::Document::Base || base == LucidData::Vertex::Base
|
146
147
|
|
147
148
|
base.instance_exec do
|
148
|
-
def
|
149
|
-
|
150
|
-
revision =
|
151
|
-
attributes =
|
152
|
-
|
153
|
-
end
|
154
|
-
|
155
|
-
def save(key:, revision: nil, attributes: nil, pub_sub_client: nil, current_user: nil)
|
156
|
-
attributes = {} unless attributes
|
157
|
-
_validate_attributes(attributes)
|
158
|
-
data = instance_exec(key: key, revision: revision, attributes: attributes,
|
159
|
-
pub_sub_client: pub_sub_client, current_user: current_user, &@_save_block)
|
160
|
-
revision = data.delete(:revision)
|
161
|
-
attributes = data.delete(:attributes)
|
162
|
-
self.new(key: key, revision: revision, attributes: attributes)
|
149
|
+
def instance_from_transport(instance_data, _included_items_data)
|
150
|
+
key = instance_data[self.name].keys.first
|
151
|
+
revision = instance_data[self.name][key].key?('revision') ? instance_data[self.name][key]['revision'] : nil
|
152
|
+
attributes = instance_data[self.name][key].key?('attributes') ? instance_data[self.name][key]['attributes'] : nil
|
153
|
+
new(key: key, revision: revision, attributes: attributes)
|
163
154
|
end
|
164
155
|
end
|
165
156
|
|
@@ -176,6 +167,10 @@ module LucidData
|
|
176
167
|
@_raw_attributes = attributes
|
177
168
|
end
|
178
169
|
|
170
|
+
def _unchange!
|
171
|
+
@_changed = false
|
172
|
+
end
|
173
|
+
|
179
174
|
def each(&block)
|
180
175
|
@_raw_attributes.each(&block)
|
181
176
|
end
|