isomorfeus-data 1.0.0.zeta25 → 2.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +47 -21
  3. data/README.md +38 -46
  4. data/lib/isomorfeus/data/attribute_support.rb +176 -176
  5. data/lib/isomorfeus/data/config.rb +79 -110
  6. data/lib/isomorfeus/data/element_validator.rb +147 -147
  7. data/lib/isomorfeus/data/ferret_accelerator.rb +66 -0
  8. data/lib/isomorfeus/data/field_support.rb +110 -0
  9. data/lib/isomorfeus/data/generic_class_api.rb +136 -116
  10. data/lib/isomorfeus/data/generic_instance_api.rb +150 -145
  11. data/lib/isomorfeus/data/hamster_accelerator.rb +87 -0
  12. data/lib/isomorfeus/data/hamster_storage_expander.rb +94 -0
  13. data/lib/isomorfeus/data/handler/generic.rb +134 -138
  14. data/lib/isomorfeus/data/reducer.rb +30 -30
  15. data/lib/isomorfeus/data/version.rb +4 -4
  16. data/lib/isomorfeus-data.rb +56 -64
  17. data/lib/isomorfeus_data/lucid_document/base.rb +10 -0
  18. data/lib/isomorfeus_data/lucid_document/mixin.rb +148 -0
  19. data/lib/isomorfeus_data/lucid_file/base.rb +10 -0
  20. data/lib/isomorfeus_data/lucid_file/mixin.rb +217 -0
  21. data/lib/isomorfeus_data/lucid_object/base.rb +10 -0
  22. data/lib/isomorfeus_data/lucid_object/mixin.rb +216 -0
  23. data/lib/isomorfeus_data/lucid_query/base.rb +10 -0
  24. data/lib/isomorfeus_data/lucid_query/mixin.rb +81 -0
  25. data/lib/isomorfeus_data/lucid_query_result.rb +97 -0
  26. data/opal/uri/common.rb +18 -0
  27. data/opal/uri/generic.rb +47 -0
  28. data/opal/uri.rb +29 -0
  29. metadata +85 -96
  30. data/lib/isomorfeus/data/handler/arango.rb +0 -56
  31. data/lib/isomorfeus/data/handler/object_call.rb +0 -40
  32. data/lib/isomorfeus/data/handler/object_store.rb +0 -40
  33. data/lib/isomorfeus_data/lucid_data/array/base.rb +0 -13
  34. data/lib/isomorfeus_data/lucid_data/array/mixin.rb +0 -580
  35. data/lib/isomorfeus_data/lucid_data/collection/base.rb +0 -13
  36. data/lib/isomorfeus_data/lucid_data/collection/finders.rb +0 -83
  37. data/lib/isomorfeus_data/lucid_data/collection/mixin.rb +0 -737
  38. data/lib/isomorfeus_data/lucid_data/composition/base.rb +0 -13
  39. data/lib/isomorfeus_data/lucid_data/composition/mixin.rb +0 -234
  40. data/lib/isomorfeus_data/lucid_data/document/base.rb +0 -13
  41. data/lib/isomorfeus_data/lucid_data/document/mixin.rb +0 -9
  42. data/lib/isomorfeus_data/lucid_data/edge/base.rb +0 -13
  43. data/lib/isomorfeus_data/lucid_data/edge/mixin.rb +0 -286
  44. data/lib/isomorfeus_data/lucid_data/edge_collection/base.rb +0 -13
  45. data/lib/isomorfeus_data/lucid_data/edge_collection/finders.rb +0 -134
  46. data/lib/isomorfeus_data/lucid_data/edge_collection/mixin.rb +0 -747
  47. data/lib/isomorfeus_data/lucid_data/generic_collection.rb +0 -4
  48. data/lib/isomorfeus_data/lucid_data/generic_edge.rb +0 -4
  49. data/lib/isomorfeus_data/lucid_data/generic_edge_collection.rb +0 -4
  50. data/lib/isomorfeus_data/lucid_data/generic_node.rb +0 -4
  51. data/lib/isomorfeus_data/lucid_data/graph/base.rb +0 -13
  52. data/lib/isomorfeus_data/lucid_data/graph/finders.rb +0 -141
  53. data/lib/isomorfeus_data/lucid_data/graph/mixin.rb +0 -489
  54. data/lib/isomorfeus_data/lucid_data/hash/base.rb +0 -13
  55. data/lib/isomorfeus_data/lucid_data/hash/mixin.rb +0 -427
  56. data/lib/isomorfeus_data/lucid_data/link/base.rb +0 -13
  57. data/lib/isomorfeus_data/lucid_data/link/mixin.rb +0 -9
  58. data/lib/isomorfeus_data/lucid_data/link_collection/base.rb +0 -13
  59. data/lib/isomorfeus_data/lucid_data/link_collection/mixin.rb +0 -9
  60. data/lib/isomorfeus_data/lucid_data/node/base.rb +0 -13
  61. data/lib/isomorfeus_data/lucid_data/node/mixin.rb +0 -232
  62. data/lib/isomorfeus_data/lucid_data/query/base.rb +0 -13
  63. data/lib/isomorfeus_data/lucid_data/query/mixin.rb +0 -83
  64. data/lib/isomorfeus_data/lucid_data/query_result.rb +0 -95
  65. data/lib/isomorfeus_data/lucid_data/vertex/base.rb +0 -13
  66. data/lib/isomorfeus_data/lucid_data/vertex/mixin.rb +0 -9
  67. data/lib/lucid_arango/collection/base.rb +0 -13
  68. data/lib/lucid_arango/collection/mixin.rb +0 -18
  69. data/lib/lucid_arango/document/base.rb +0 -13
  70. data/lib/lucid_arango/document/mixin.rb +0 -9
  71. data/lib/lucid_arango/edge/base.rb +0 -13
  72. data/lib/lucid_arango/edge/mixin.rb +0 -18
  73. data/lib/lucid_arango/edge_collection/base.rb +0 -13
  74. data/lib/lucid_arango/edge_collection/mixin.rb +0 -18
  75. data/lib/lucid_arango/graph/base.rb +0 -13
  76. data/lib/lucid_arango/graph/mixin.rb +0 -18
  77. data/lib/lucid_arango/node/base.rb +0 -13
  78. data/lib/lucid_arango/node/mixin.rb +0 -79
  79. data/lib/lucid_arango/object/base.rb +0 -11
  80. data/lib/lucid_arango/object/mixin.rb +0 -158
  81. data/lib/lucid_arango/remote_object/base.rb +0 -11
  82. data/lib/lucid_arango/remote_object/mixin.rb +0 -17
  83. data/lib/lucid_arango/vertex/base.rb +0 -13
  84. data/lib/lucid_arango/vertex/mixin.rb +0 -9
@@ -1,747 +0,0 @@
1
- module LucidData
2
- module EdgeCollection
3
- module Mixin
4
- def self.included(base)
5
- base.include(Enumerable)
6
- base.include(Isomorfeus::Data::AttributeSupport)
7
- base.extend(Isomorfeus::Data::GenericClassApi)
8
- base.include(Isomorfeus::Data::GenericInstanceApi)
9
- base.include(LucidData::EdgeCollection::Finders)
10
-
11
- base.instance_exec do
12
- def edges(validate_hash)
13
- @edge_conditions = validate_hash
14
- end
15
- alias links edges
16
-
17
- def edge_conditions
18
- @edge_conditions ||= {}
19
- end
20
-
21
- def valid_edge?(edge)
22
- return true unless edge_conditions.any?
23
- _validate_edge(edge)
24
- rescue
25
- false
26
- end
27
- alias valid_link? valid_edge?
28
-
29
- def _validate_edge(edge)
30
- Isomorfeus::Data::ElementValidator.new(self.to_s, edge, edge_conditions).validate!
31
- end
32
-
33
- def _validate_edges(many_edges)
34
- many_edges.each { |edge| _validate_edge(edge) } if edge_conditions.any?
35
- end
36
- end
37
-
38
- def _validate_edge(edge)
39
- self.class._validate_edge(edge)
40
- end
41
-
42
- def _validate_edges(many_edges)
43
- self.class._validate_edges(many_edges)
44
- end
45
-
46
- def _collection_to_sids(collection)
47
- collection.map do |edge|
48
- edge.respond_to?(:to_sid) ? edge.to_sid : edge
49
- end
50
- end
51
-
52
- def _edge_sid_from_arg(arg)
53
- if arg.respond_to?(:to_sid)
54
- sid = arg.to_sid
55
- edge = arg
56
- else
57
- sid = arg
58
- edge = Isomorfeus.instance_from_sid(sid)
59
- edge.collection = self
60
- end
61
- [edge, sid]
62
- end
63
-
64
- def graph
65
- @_graph
66
- end
67
-
68
- def graph=(g)
69
- @_graph = g
70
- end
71
-
72
- def composition
73
- @_composition
74
- end
75
-
76
- def composition=(c)
77
- @_composition = c
78
- end
79
-
80
- def changed?
81
- @_changed
82
- end
83
-
84
- def changed!
85
- @_graph.changed! if @_graph
86
- @_composition.changed! if @_composition
87
- @_changed = true
88
- end
89
-
90
- def update_node_to_edge_cache(edge, old_node, new_node)
91
- old_node_sid = old_node.to_sid
92
- new_node_sid = new_node.to_sid
93
- edge_sid = edge.to_sid
94
- if @_node_to_edge_cache.key?(old_node_sid)
95
- @_node_to_edge_cache[old_node_sid].delete_if { |node_edge| node_edge.to_sid == edge_sid }
96
- end
97
- @_node_to_edge_cache[new_node_sid].push(edge) if @_node_to_edge_cache.key?(new_node_sid)
98
- end
99
-
100
- def to_transport
101
- hash = { 'attributes' => _get_selected_attributes, 'edges' => edges_as_sids }
102
- hash.merge!('revision' => revision) if revision
103
- result = { @class_name => { @key => hash }}
104
- result.deep_merge!(@class_name => { @previous_key => { new_key: @key}}) if @previous_key
105
- result
106
- end
107
-
108
- def included_items_to_transport
109
- edges_hash = {}
110
- edges.each do |edge|
111
- edges_hash.deep_merge!(edge.to_transport)
112
- end
113
- edges_hash
114
- end
115
-
116
- if RUBY_ENGINE == 'opal'
117
- def initialize(key:, revision: nil, attributes: nil, edges: nil, links: nil, graph: nil, composition: nil)
118
- @key = key.to_s
119
- @class_name = self.class.name
120
- @class_name = @class_name.split('>::').last if @class_name.start_with?('#<')
121
- _update_paths
122
- @_revision = revision ? revision : Redux.fetch_by_path(:data_state, @class_name, @key, :revision)
123
- @_graph = graph
124
- @_composition = composition
125
- @_node_to_edge_cache = {}
126
- @_changed_collection = nil
127
- @_validate_edges = self.class.edge_conditions.any?
128
-
129
- loaded = loaded?
130
-
131
- if attributes
132
- _validate_attributes(attributes)
133
- if loaded
134
- raw_attributes = Redux.fetch_by_path(*@_store_path)
135
- if `raw_attributes === null`
136
- @_changed_attributes = !attributes ? {} : attributes
137
- elsif raw_attributes && !attributes.nil? && ::Hash.new(raw_attributes) != attributes
138
- @_changed_attributes = attributes
139
- end
140
- else
141
- @_changed_attributes = attributes
142
- end
143
- else
144
- @_changed_attributes = {}
145
- end
146
-
147
- edges = edges || links
148
- if edges && loaded
149
- _validate_edges(edges)
150
- raw_edges = _collection_to_sids(edges)
151
- raw_collection = Redux.fetch_by_path(*@_edges_path)
152
- if raw_collection != raw_edges
153
- @_changed_collection = raw_edges
154
- end
155
- elsif !loaded
156
- @_changed_collection = []
157
- end
158
- end
159
-
160
- def _load_from_store!
161
- @_changed = false
162
- @_changed_attributes = {}
163
- @_changed_collection = nil
164
- end
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
-
171
- def edges
172
- edges_as_sids.map do |edge_sid|
173
- edge = Isomorfeus.instance_from_sid(edge_sid)
174
- edge.collection = self
175
- edge
176
- end
177
- end
178
- alias links edges
179
-
180
- def edges_as_sids
181
- return @_changed_collection if @_changed_collection
182
- collection = Redux.fetch_by_path(*@_edges_path)
183
- return collection if collection
184
- []
185
- end
186
-
187
- def edges_for_node(node)
188
- node_sid = node.respond_to?(:to_sid) ? node.to_sid : node
189
- return @_node_to_edge_cache[node_sid] if @_node_to_edge_cache.key?(node_sid)
190
- node_edge_sids = edges_as_sids.select do |edge_sid|
191
- edge_data = Redux.fetch_by_path(:data_state, edge_sid[0], edge_sid[1])
192
- (edge_data.JS[:from] == node_sid || edge_data.JS[:to] == node_sid) ? true : false
193
- end
194
- node_edges = node_edge_sids.map do |edge_sid|
195
- edge = Isomorfeus.instance_from_sid(edge_sid)
196
- edge.collection = self
197
- edge
198
- end
199
- @_node_to_edge_cache[node_sid] = node_edges
200
- end
201
- alias edges_for_vertex edges_for_node
202
- alias edges_for_document edges_for_node
203
-
204
- def each(&block)
205
- edges.each(&block)
206
- end
207
-
208
- def method_missing(method_name, *args, &block)
209
- if method_name.JS.startsWith('find_edge_by_') || method_name.JS.startsWith('find_link_by_')
210
- attribute = method_name[13..-1] # remove 'find_edge_by_'
211
- value = args[0]
212
- attribute_hash = { attribute => value }
213
- attribute_hash.merge!(args[1]) if args[1]
214
- find_edge(attribute_hash)
215
- else
216
- collection = edges
217
- collection.send(method_name, *args, &block)
218
- end
219
- end
220
-
221
- def <<(edge)
222
- edge, sid = _edge_sid_from_arg(edge)
223
- _validate_edge(edge) if @_validate_edges
224
- raw_collection = edges_as_sids
225
- @_changed_collection = raw_collection << sid
226
- changed!
227
- self
228
- end
229
-
230
- def [](idx)
231
- sid = edges_as_sids[idx]
232
- edge = Isomorfeus.instance_from_sid(sid)
233
- edge.collection = self
234
- edge
235
- end
236
-
237
- def []=(idx, edge)
238
- edge, sid = _edge_sid_from_arg(edge)
239
- _validate_edge(edge) if @_validate_edges
240
- raw_collection = edges_as_sids
241
- raw_collection[idx] = sid
242
- @_changed_collection = raw_collection
243
- changed!
244
- edge
245
- end
246
-
247
- def clear
248
- @_changed_collection = []
249
- changed!
250
- self
251
- end
252
-
253
- def collect!(&block)
254
- collection = edges
255
- collection.collect!(&block)
256
- @_changed_collection = _collection_to_sids(collection)
257
- changed!
258
- self
259
- end
260
-
261
- def compact!
262
- raw_collection = edges_as_sids
263
- result = raw_collection.compact!
264
- return nil if result.nil?
265
- @_changed_collection = raw_collection
266
- changed!
267
- self
268
- end
269
-
270
- def concat(*args)
271
- sids = args.map do |edge|
272
- edge, sid = _edge_sid_from_arg(edge)
273
- _validate_edge(edge)
274
- sid
275
- end
276
- raw_collection = edges_as_sids
277
- raw_collection.concat(*sids)
278
- @_changed_collection = raw_collection
279
- changed!
280
- self
281
- end
282
-
283
- def delete(edge, &block)
284
- edge, sid = _edge_sid_from_arg(edge)
285
- raw_collection = edges_as_sids
286
- result = raw_collection.delete(sid, &block)
287
- return nil unless result
288
- @_changed_collection = raw_collection
289
- changed!
290
- edge
291
- end
292
-
293
- def delete_at(idx)
294
- raw_collection = edges_as_sids
295
- result = raw_collection.delete_at(idx)
296
- return nil if result.nil?
297
- @_changed_collection = raw_collection
298
- changed!
299
- Isomorfeus.instance_from_sid(result)
300
- end
301
-
302
- def delete_if(&block)
303
- collection = edges
304
- collection.delete_if(&block)
305
- @_changed_collection = _collection_to_sids(collection)
306
- changed!
307
- self
308
- end
309
-
310
- def filter!(&block)
311
- collection = edges
312
- result = collection.filter!(&block)
313
- return nil if result.nil?
314
- @_changed_collection = _collection_to_sids(collection)
315
- changed!
316
- self
317
- end
318
-
319
- def insert(index, *many_edges)
320
- sids = many_edges.map do |edge|
321
- edge, sid = _edge_sid_from_arg(edge)
322
- _validate_edge(edge)
323
- sid
324
- end
325
- raw_collection = edges_as_sids
326
- raw_collection.insert(index, sids)
327
- @_changed_collection = raw_collection
328
- changed!
329
- self
330
- end
331
-
332
- def keep_if(&block)
333
- collection = edges
334
- collection.keep_if(&block)
335
- @_changed_collection = _collection_to_sids(collection)
336
- changed!
337
- self
338
- end
339
-
340
- def map!(&block)
341
- collection = edges
342
- collection.map!(&block)
343
- @_changed_collection = _collection_to_sids(collection)
344
- changed!
345
- self
346
- end
347
-
348
- def pop(n = nil)
349
- raw_collection = edges_as_sids
350
- result = raw_collection.pop(n)
351
- @_changed_collection = raw_collection
352
- changed!
353
- Isomorfeus.instance_from_sid(result)
354
- end
355
-
356
- def push(*edges)
357
- sids = many_edges.map do |edge|
358
- edge, sid = _edge_sid_from_arg(edge)
359
- _validate_edge(edge)
360
- sid
361
- end
362
- raw_collection = edges_as_sids
363
- raw_collection.push(*sids)
364
- @_changed_collection = raw_collection
365
- changed!
366
- self
367
- end
368
- alias append push
369
-
370
- def reject!(&block)
371
- collection = edges
372
- result = collection.reject!(&block)
373
- return nil if result.nil?
374
- @_changed_collection = _collection_to_sids(collection)
375
- changed!
376
- self
377
- end
378
-
379
- def reverse!
380
- raw_collection = edges_as_sids
381
- raw_collection.reverse!
382
- @_changed_collection = raw_collection
383
- changed!
384
- self
385
- end
386
-
387
- def rotate!(count = 1)
388
- raw_collection = edges_as_sids
389
- raw_collection.rotate!(count)
390
- @_changed_collection = raw_collection
391
- changed!
392
- self
393
- end
394
-
395
- def select!(&block)
396
- collection = edges
397
- result = collection.select!(&block)
398
- return nil if result.nil?
399
- @_changed_collection = _collection_to_sids(collection)
400
- changed!
401
- self
402
- end
403
-
404
- def shift(n = nil)
405
- raw_collection = edges_as_sids
406
- result = raw_collection.shift(n)
407
- @_changed_collection = raw_collection
408
- changed!
409
- Isomorfeus.instance_from_sid(result)
410
- end
411
-
412
- def shuffle!(*args)
413
- raw_collection = edges_as_sids
414
- raw_collection.shuffle!(*args)
415
- @_changed_collection = raw_collection
416
- changed!
417
- self
418
- end
419
-
420
- def slice!(*args)
421
- raw_collection = edges_as_sids
422
- result = raw_collection.slice!(*args)
423
- @_changed_collection = raw_collection
424
- changed!
425
- return nil if result.nil?
426
- # TODO
427
- result
428
- end
429
-
430
- def sort!(&block)
431
- collection = edges
432
- collection.sort!(&block)
433
- @_changed_collection = _collection_to_sids(collection)
434
- self
435
- end
436
-
437
- def sort_by!(&block)
438
- collection = edges
439
- collection.sort_by!(&block)
440
- @_changed_collection = _collection_to_sids(collection)
441
- changed!
442
- self
443
- end
444
-
445
- def uniq!(&block)
446
- collection = edges
447
- collection.uniq!(&block)
448
- @_changed_collection = _collection_to_sids(collection)
449
- changed!
450
- self
451
- end
452
-
453
- def unshift(*many_edges)
454
- sids = many_edges.map do |edge|
455
- edge, sid = _edge_sid_from_arg(edge)
456
- _validate_edge(edge)
457
- sid
458
- end
459
- raw_collection = edges_as_sids
460
- raw_collection.unshift(*sids)
461
- @_changed_collection = raw_collection
462
- changed!
463
- self
464
- end
465
- alias prepend unshift
466
- else # RUBY_ENGINE
467
- Isomorfeus.add_valid_data_class(base) unless base == LucidData::EdgeCollection::Base || base == LucidData::LinkCollection::Base
468
-
469
- base.instance_exec do
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'].transform_keys!(&:to_sym) : 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(message: "#{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(message: "#{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(message: "#{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
- end
490
- end
491
-
492
- def initialize(key:, revision: nil, attributes: nil, edges: nil, links: nil, graph: nil, composition: nil)
493
- @key = key.to_s
494
- @class_name = self.class.name
495
- @class_name = @class_name.split('>::').last if @class_name.start_with?('#<')
496
- @_revision = revision
497
- @_graph = graph
498
- @_composition = composition
499
- @_node_to_edge_cache = {}
500
- @_changed = false
501
- @_validate_attributes = self.class.attribute_conditions.any?
502
- @_validate_edges = self.class.edge_conditions.any?
503
-
504
- attributes = {} unless attributes
505
- _validate_attributes(attributes) if attributes
506
- @_raw_attributes = attributes
507
-
508
- edges = edges || links
509
- edges = [] unless edges
510
- _validate_edges(edges) if @_validate_edges
511
- edges.each { |e| e.collection = self }
512
- @_raw_collection = edges
513
- end
514
-
515
- def _unchange!
516
- @changed = false
517
- end
518
-
519
- def edges
520
- @_raw_collection
521
- end
522
- alias links edges
523
-
524
- def edges_as_sids
525
- @_raw_collection.map(&:to_sid)
526
- end
527
-
528
- def edges_for_node(node)
529
- node_sid = node.respond_to?(:to_sid) ? node.to_sid : node
530
- return @_node_to_edge_cache[node_sid] if @_node_to_edge_cache.key?(node_sid)
531
- node_edges = select do |edge|
532
- (edge.from_as_sid == node_sid || edge.to_as_sid == node_sid) ? true : false
533
- end
534
- @_node_to_edge_cache[node_sid] = node_edges
535
- end
536
- alias edges_for_vertex edges_for_node
537
- alias edges_for_document edges_for_node
538
-
539
- def each(&block)
540
- @_raw_collection.each(&block)
541
- end
542
-
543
- def method_missing(method_name, *args, &block)
544
- method_name_s = method_name.to_s
545
- if method_name_s.start_with?('find_by_')
546
- attribute = method_name_s[8..-1] # remove 'find_by_'
547
- value = args[0]
548
- attribute_hash = { attribute => value }
549
- attribute_hash.merge!(args[1]) if args[1]
550
- find(attribute_hash)
551
- else
552
- @_raw_collection.send(method_name, *args, &block)
553
- end
554
- end
555
-
556
- def <<(edge)
557
- _validate_edge(edge) if @_validate_edges
558
- changed!
559
- @_raw_collection << edge
560
- edge
561
- end
562
-
563
- def []=(idx, edge)
564
- _validate_edge(edge) if @_validate_edges
565
- changed!
566
- @_raw_collection[idx] = edge
567
- end
568
-
569
- def clear
570
- changed!
571
- @_raw_collection = []
572
- self
573
- end
574
-
575
- def collect!(&block)
576
- changed!
577
- @_raw_collection.collect!(&block)
578
- self
579
- end
580
-
581
- def compact!
582
- @_raw_collection.compact!
583
- return nil if result.nil?
584
- changed!
585
- self
586
- end
587
-
588
- def concat(*many_edges)
589
- if @_validate_edges
590
- many_edges = many_edges.map do |edge|
591
- _validate_edge(edge)
592
- edge
593
- end
594
- end
595
- changed!
596
- @_raw_collection.concat(*many_edges)
597
- self
598
- end
599
-
600
- def delete(edge, &block)
601
- result = @_raw_collection.delete(edge, &block)
602
- changed!
603
- result
604
- end
605
-
606
- def delete_at(idx)
607
- result = @_raw_collection.delete_at(idx)
608
- return nil if result.nil?
609
- changed!
610
- result
611
- end
612
-
613
- def delete_if(&block)
614
- @_raw_collection.delete_if(&block)
615
- changed!
616
- self
617
- end
618
-
619
- def filter!(&block)
620
- result = @_raw_collection.filter!(&block)
621
- return nil if result.nil?
622
- changed!
623
- self
624
- end
625
-
626
- def insert(idx, *many_edges)
627
- if @_validate_edges
628
- many_edges = many_edges.map do |edge|
629
- _validate_edge(edge)
630
- edge
631
- end
632
- end
633
- @_raw_collection.insert(idx, *many_edges)
634
- changed!
635
- self
636
- end
637
-
638
- def keep_if(&block)
639
- @_raw_collection.keep_if(&block)
640
- changed!
641
- self
642
- end
643
-
644
- def map!(&block)
645
- @_raw_collection.map!(&block)
646
- changed!
647
- self
648
- end
649
-
650
- def pop(n = nil)
651
- result = @_raw_collection.pop(n)
652
- changed!
653
- result
654
- end
655
-
656
- def push(*many_edges)
657
- if @_validate_edges
658
- many_edges = many_edges.map do |edge|
659
- _validate_edge(edge)
660
- edge
661
- end
662
- end
663
- @_raw_collection.push(*many_edges)
664
- changed!
665
- self
666
- end
667
- alias append push
668
-
669
- def reject!(&block)
670
- result = @_raw_collection.reject!(&block)
671
- return nil if result.nil?
672
- changed!
673
- self
674
- end
675
-
676
- def reverse!
677
- @_raw_collection.reverse!
678
- changed!
679
- self
680
- end
681
-
682
- def rotate!(count = 1)
683
- @_raw_collection.rotate!(count)
684
- changed!
685
- self
686
- end
687
-
688
- def select!(&block)
689
- result = @_raw_collection.select!(&block)
690
- return nil if result.nil?
691
- changed!
692
- self
693
- end
694
-
695
- def shift(n = nil)
696
- result = @_raw_collection.shift(n)
697
- changed!
698
- result
699
- end
700
-
701
- def shuffle!(*args)
702
- @_raw_collection.shuffle!(*args)
703
- changed!
704
- self
705
- end
706
-
707
- def slice!(*args)
708
- result = @_raw_collection.slice!(*args)
709
- changed!
710
- result
711
- end
712
-
713
- def sort!(&block)
714
- @_raw_collection.sort!(&block)
715
- changed!
716
- self
717
- end
718
-
719
- def sort_by!(&block)
720
- @_raw_collection.sort_by!(&block)
721
- changed!
722
- self
723
- end
724
-
725
- def uniq!(&block)
726
- @_raw_collection.uniq!(&block)
727
- changed!
728
- self
729
- end
730
-
731
- def unshift(*many_edges)
732
- if @_validate_edges
733
- many_edges = many_edges.map do |edge|
734
- _validate_edge(edge)
735
- edge
736
- end
737
- end
738
- @_raw_collection.unshift(*many_edges)
739
- changed!
740
- self
741
- end
742
- alias prepend unshift
743
- end # RUBY_ENGINE
744
- end
745
- end
746
- end
747
- end