isomorfeus-data 1.0.0.zeta5 → 1.0.0.zeta6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +37 -1
- data/lib/isomorfeus/data/attribute_support.rb +122 -0
- data/lib/isomorfeus/data/config.rb +79 -89
- data/lib/isomorfeus/data/element_validator.rb +133 -0
- data/lib/isomorfeus/data/generic_class_api.rb +155 -0
- data/lib/isomorfeus/data/generic_instance_api.rb +72 -0
- data/lib/isomorfeus/data/handler/arango.rb +61 -0
- data/lib/isomorfeus/data/handler/generic.rb +92 -0
- data/lib/isomorfeus/data/handler/object_call.rb +45 -0
- data/lib/isomorfeus/data/handler/object_store.rb +45 -0
- data/lib/isomorfeus/data/version.rb +1 -1
- data/lib/isomorfeus-data.rb +61 -30
- data/lib/isomorfeus_data/lucid_data/array/base.rb +15 -0
- data/lib/isomorfeus_data/lucid_data/array/mixin.rb +570 -0
- data/lib/isomorfeus_data/lucid_data/collection/base.rb +15 -0
- data/lib/isomorfeus_data/lucid_data/collection/finders.rb +83 -0
- data/lib/isomorfeus_data/lucid_data/collection/mixin.rb +710 -0
- data/lib/isomorfeus_data/lucid_data/composition/base.rb +15 -0
- data/lib/isomorfeus_data/lucid_data/composition/mixin.rb +185 -0
- data/lib/isomorfeus_data/lucid_data/document/base.rb +15 -0
- data/lib/isomorfeus_data/lucid_data/document/mixin.rb +9 -0
- data/lib/isomorfeus_data/lucid_data/edge/base.rb +15 -0
- data/lib/isomorfeus_data/lucid_data/edge/mixin.rb +281 -0
- data/lib/isomorfeus_data/lucid_data/edge_collection/base.rb +15 -0
- data/lib/isomorfeus_data/lucid_data/edge_collection/finders.rb +134 -0
- data/lib/isomorfeus_data/lucid_data/edge_collection/mixin.rb +705 -0
- data/lib/isomorfeus_data/lucid_data/graph/base.rb +15 -0
- data/lib/isomorfeus_data/lucid_data/graph/finders.rb +141 -0
- data/lib/isomorfeus_data/lucid_data/graph/mixin.rb +401 -0
- data/lib/isomorfeus_data/lucid_data/hash/base.rb +15 -0
- data/lib/isomorfeus_data/lucid_data/hash/mixin.rb +413 -0
- data/lib/isomorfeus_data/lucid_data/link/base.rb +15 -0
- data/lib/isomorfeus_data/lucid_data/link/mixin.rb +9 -0
- data/lib/isomorfeus_data/lucid_data/link_collection/base.rb +15 -0
- data/lib/isomorfeus_data/lucid_data/link_collection/mixin.rb +9 -0
- data/lib/isomorfeus_data/lucid_data/node/base.rb +15 -0
- data/lib/isomorfeus_data/lucid_data/node/mixin.rb +192 -0
- data/lib/isomorfeus_data/lucid_data/object/base.rb +13 -0
- data/lib/{lucid_array → isomorfeus_data/lucid_data/object}/mixin.rb +15 -16
- data/lib/isomorfeus_data/lucid_data/remote_object/base.rb +13 -0
- data/lib/isomorfeus_data/lucid_data/remote_object/mixin.rb +19 -0
- data/lib/isomorfeus_data/lucid_data/vertex/base.rb +15 -0
- data/lib/isomorfeus_data/lucid_data/vertex/mixin.rb +9 -0
- data/lib/lucid_arango/collection/base.rb +15 -0
- data/lib/lucid_arango/collection/mixin.rb +20 -0
- data/lib/lucid_arango/document/base.rb +15 -0
- data/lib/lucid_arango/document/mixin.rb +9 -0
- data/lib/lucid_arango/edge/base.rb +16 -0
- data/lib/lucid_arango/edge/mixin.rb +20 -0
- data/lib/lucid_arango/edge_collection/base.rb +15 -0
- data/lib/lucid_arango/edge_collection/mixin.rb +20 -0
- data/lib/lucid_arango/graph/base.rb +15 -0
- data/lib/lucid_arango/graph/mixin.rb +20 -0
- data/lib/lucid_arango/node/base.rb +16 -0
- data/lib/lucid_arango/node/mixin.rb +81 -0
- data/lib/lucid_arango/vertex/base.rb +15 -0
- data/lib/lucid_arango/vertex/mixin.rb +9 -0
- metadata +84 -47
- data/lib/isomorfeus/data/handler/array_load_handler.rb +0 -47
- data/lib/isomorfeus/data/handler/collection_load_handler.rb +0 -48
- data/lib/isomorfeus/data/handler/graph_load_handler.rb +0 -48
- data/lib/isomorfeus/data/handler/hash_load_handler.rb +0 -47
- data/lib/lucid_array/base.rb +0 -14
- data/lib/lucid_collection/base.rb +0 -14
- data/lib/lucid_collection/mixin.rb +0 -241
- data/lib/lucid_edge/base.rb +0 -5
- data/lib/lucid_edge/mixin.rb +0 -238
- data/lib/lucid_graph/base.rb +0 -14
- data/lib/lucid_graph/mixin.rb +0 -670
- data/lib/lucid_hash/base.rb +0 -14
- data/lib/lucid_hash/mixin.rb +0 -168
- data/lib/lucid_node/base.rb +0 -5
- data/lib/lucid_node/mixin.rb +0 -198
@@ -1,11 +1,11 @@
|
|
1
|
-
module
|
1
|
+
module LucidStorableObject
|
2
2
|
module Mixin
|
3
|
+
# TODO on revision conflict
|
3
4
|
def self.included(base)
|
4
|
-
|
5
|
-
Isomorfeus.add_valid_array_class(base) unless base == LucidArray::Base
|
6
|
-
end
|
7
|
-
|
5
|
+
base.include(Enumerable)
|
8
6
|
base.extend(LucidPropDeclaration::Mixin)
|
7
|
+
base.extend(Isomorfeus::Data::GenericClassApi)
|
8
|
+
base.include(Isomorfeus::Data::GenericInstanceApi)
|
9
9
|
|
10
10
|
def to_gid
|
11
11
|
[@class_name, @props_json]
|
@@ -16,8 +16,8 @@ module LucidArray
|
|
16
16
|
@on_load_block
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
20
|
-
@
|
19
|
+
def load_query_block
|
20
|
+
@load_query_block
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -73,7 +73,7 @@ module LucidArray
|
|
73
73
|
|
74
74
|
props_json = instance.instance_variable_get(:@props_json)
|
75
75
|
|
76
|
-
Isomorfeus::Transport.promise_send_path('Isomorfeus::Data::Handler::
|
76
|
+
Isomorfeus::Transport.promise_send_path('Isomorfeus::Data::Handler::Generic', self.name, props_json).then do |agent|
|
77
77
|
if agent.processed
|
78
78
|
agent.result
|
79
79
|
else
|
@@ -88,14 +88,13 @@ module LucidArray
|
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
|
-
def
|
92
|
-
nil
|
93
|
-
end
|
91
|
+
def load_query; end
|
94
92
|
end
|
95
93
|
else # RUBY_ENGINE
|
96
|
-
unless base ==
|
94
|
+
unless base == LucidStorableObject::Base
|
95
|
+
Isomorfeus.add_valid_data_class(base)
|
97
96
|
base.prop :pub_sub_client, default: nil
|
98
|
-
base.prop :current_user, default:
|
97
|
+
base.prop :current_user, default: Anonymous.new
|
99
98
|
end
|
100
99
|
|
101
100
|
def initialize(store_path: nil, validated_props: nil)
|
@@ -135,7 +134,7 @@ module LucidArray
|
|
135
134
|
validate_props(props_hash)
|
136
135
|
instance = self.new(validated_props: Isomorfeus::Data::Props.new(props_hash))
|
137
136
|
instance.instance_exec do
|
138
|
-
@data_array = self.class.
|
137
|
+
@data_array = self.class.load_query_block.call(props_hash)
|
139
138
|
@loaded = true
|
140
139
|
end
|
141
140
|
instance
|
@@ -152,8 +151,8 @@ module LucidArray
|
|
152
151
|
result_promise
|
153
152
|
end
|
154
153
|
|
155
|
-
def
|
156
|
-
@
|
154
|
+
def load_query(&block)
|
155
|
+
@load_query_block = block
|
157
156
|
end
|
158
157
|
end
|
159
158
|
end # RUBY_ENGINE
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module LucidRemoteObject
|
2
|
+
class Base
|
3
|
+
include LucidRemoteObject::Mixin
|
4
|
+
|
5
|
+
if RUBY_ENGINE != 'opal'
|
6
|
+
def self.inherited(base)
|
7
|
+
Isomorfeus.add_valid_data_class(base)
|
8
|
+
base.prop :pub_sub_client, default: nil
|
9
|
+
base.prop :current_user, default: Anonymous.new
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module LucidRemoteObject
|
2
|
+
module Mixin
|
3
|
+
# TODO on revision conflict
|
4
|
+
def self.included(base)
|
5
|
+
if RUBY_ENGINE != 'opal'
|
6
|
+
unless base == LucidRemoteObject::Base
|
7
|
+
Isomorfeus.add_valid_data_class(base)
|
8
|
+
base.prop :pub_sub_client, default: nil
|
9
|
+
base.prop :current_user, default: Anonymous.new
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
base.include(Enumerable)
|
14
|
+
base.extend(LucidPropDeclaration::Mixin)
|
15
|
+
base.extend(Isomorfeus::Data::GenericClassApi)
|
16
|
+
base.include(Isomorfeus::Data::GenericInstanceApi)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module LucidData
|
2
|
+
module Vertex
|
3
|
+
class Base
|
4
|
+
include LucidData::Node::Mixin
|
5
|
+
|
6
|
+
if RUBY_ENGINE != 'opal'
|
7
|
+
def self.inherited(base)
|
8
|
+
Isomorfeus.add_valid_data_class(base)
|
9
|
+
base.prop :pub_sub_client, default: nil
|
10
|
+
base.prop :current_user, default: Anonymous.new
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module LucidArango
|
2
|
+
module DocumentCollection
|
3
|
+
class Base
|
4
|
+
include LucidArango::DocumentCollection::Mixin
|
5
|
+
|
6
|
+
if RUBY_ENGINE != 'opal'
|
7
|
+
def self.inherited(base)
|
8
|
+
Isomorfeus.add_valid_data_class(base)
|
9
|
+
base.prop :pub_sub_client, default: nil
|
10
|
+
base.prop :current_user, default: Anonymous.new
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module LucidArango
|
2
|
+
module DocumentCollection
|
3
|
+
module Mixin
|
4
|
+
def self.included(base)
|
5
|
+
if RUBY_ENGINE != 'opal'
|
6
|
+
unless base == LucidArango::DocumentCollection::Base
|
7
|
+
Isomorfeus.add_valid_data_class(base)
|
8
|
+
base.prop :pub_sub_client, default: nil
|
9
|
+
base.prop :current_user, default: Anonymous.new
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
base.include(Enumerable)
|
14
|
+
base.extend(LucidPropDeclaration::Mixin)
|
15
|
+
|
16
|
+
# TODO implement, depends on arango-driver
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module LucidArango
|
2
|
+
module Document
|
3
|
+
class Base
|
4
|
+
include LucidArango::Node::Mixin
|
5
|
+
|
6
|
+
if RUBY_ENGINE != 'opal'
|
7
|
+
def self.inherited(base)
|
8
|
+
Isomorfeus.add_valid_data_class(base)
|
9
|
+
base.prop :pub_sub_client, default: nil
|
10
|
+
base.prop :current_user, default: Anonymous.new
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module LucidArango
|
2
|
+
module Edge
|
3
|
+
class Base
|
4
|
+
include LucidArango::Edge::Mixin
|
5
|
+
|
6
|
+
if RUBY_ENGINE != 'opal'
|
7
|
+
def self.inherited(base)
|
8
|
+
Isomorfeus.add_valid_data_class(base)
|
9
|
+
|
10
|
+
base.prop :pub_sub_client, default: nil
|
11
|
+
base.prop :current_user, default: Anonymous.new
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module LucidArango
|
2
|
+
module Edge
|
3
|
+
module Mixin
|
4
|
+
def self.included(base)
|
5
|
+
if RUBY_ENGINE != 'opal'
|
6
|
+
unless base == LucidArango::Edge::Base
|
7
|
+
Isomorfeus.add_valid_data_class(base)
|
8
|
+
base.prop :pub_sub_client, default: nil
|
9
|
+
base.prop :current_user, default: Anonymous.new
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
base.include(Enumerable)
|
14
|
+
base.extend(LucidPropDeclaration::Mixin)
|
15
|
+
|
16
|
+
# TODO implement, depends on arango-driver
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module LucidArango
|
2
|
+
module EdgeCollection
|
3
|
+
class Base
|
4
|
+
include LucidArango::EdgeCollection::Mixin
|
5
|
+
|
6
|
+
if RUBY_ENGINE != 'opal'
|
7
|
+
def self.inherited(base)
|
8
|
+
Isomorfeus.add_valid_data_class(base)
|
9
|
+
base.prop :pub_sub_client, default: nil
|
10
|
+
base.prop :current_user, default: Anonymous.new
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module LucidArango
|
2
|
+
module EdgeCollection
|
3
|
+
module Mixin
|
4
|
+
def self.included(base)
|
5
|
+
if RUBY_ENGINE != 'opal'
|
6
|
+
unless base == LucidArango::EdgeCollection::Base
|
7
|
+
Isomorfeus.add_valid_data_class(base)
|
8
|
+
base.prop :pub_sub_client, default: nil
|
9
|
+
base.prop :current_user, default: Anonymous.new
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
base.include(Enumerable)
|
14
|
+
base.extend(LucidPropDeclaration::Mixin)
|
15
|
+
|
16
|
+
# TODO implement, depends on arango-driver
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module LucidArango
|
2
|
+
module Graph
|
3
|
+
class Base
|
4
|
+
include LucidArango::Graph::Mixin
|
5
|
+
|
6
|
+
if RUBY_ENGINE != 'opal'
|
7
|
+
def self.inherited(base)
|
8
|
+
Isomorfeus.add_valid_data_class(base)
|
9
|
+
base.prop :pub_sub_client, default: nil
|
10
|
+
base.prop :current_user, default: Anonymous.new
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module LucidArango
|
2
|
+
module Graph
|
3
|
+
module Mixin
|
4
|
+
def self.included(base)
|
5
|
+
if RUBY_ENGINE != 'opal'
|
6
|
+
unless base == LucidArango::Graph::Base
|
7
|
+
Isomorfeus.add_valid_data_class(base)
|
8
|
+
base.prop :pub_sub_client, default: nil
|
9
|
+
base.prop :current_user, default: Anonymous.new
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
base.include(Enumerable)
|
14
|
+
base.extend(LucidPropDeclaration::Mixin)
|
15
|
+
|
16
|
+
# TODO implement, depends on arango-driver
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module LucidArango
|
2
|
+
module Document
|
3
|
+
class Base
|
4
|
+
include LucidArango::Document::Mixin
|
5
|
+
|
6
|
+
if RUBY_ENGINE != 'opal'
|
7
|
+
def self.inherited(base)
|
8
|
+
Isomorfeus.add_valid_data_class(base)
|
9
|
+
|
10
|
+
base.prop :pub_sub_client, default: nil
|
11
|
+
base.prop :current_user, default: Anonymous.new
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
module LucidArango
|
2
|
+
module Document
|
3
|
+
module Mixin
|
4
|
+
def self.included(base)
|
5
|
+
base.include(Enumerable)
|
6
|
+
base.extend(LucidPropDeclaration::Mixin)
|
7
|
+
base.extend(Isomorfeus::Data::GenericClassApi)
|
8
|
+
base.include(Isomorfeus::Data::GenericInstanceApi)
|
9
|
+
# TODO implement, depends on arango-driver
|
10
|
+
|
11
|
+
base.instance_exec do
|
12
|
+
def attribute_conditions
|
13
|
+
@attribute_conditions ||= {}
|
14
|
+
end
|
15
|
+
|
16
|
+
def valid_attribute?(attr_name, attr_value)
|
17
|
+
return true unless @attribute_conditions
|
18
|
+
Isomorfeus::Props::Validator.new(self.name, attr_name, attr_value, attribute_conditions[attr_name]).validate!
|
19
|
+
rescue
|
20
|
+
false
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_transport
|
25
|
+
{ @class_name => { @key => to_h }}
|
26
|
+
end
|
27
|
+
|
28
|
+
def _validate_attribute(attr_name, attr_val)
|
29
|
+
Isomorfeus::Props::Validator.new(@class_name, attr_name, attr_val, self.class.attribute_conditions[attr_name]).validate!
|
30
|
+
end
|
31
|
+
|
32
|
+
if RUBY_ENGINE == 'opal'
|
33
|
+
base.instance_exec do
|
34
|
+
def attribute(name, options = {})
|
35
|
+
attribute_conditions[name] = options
|
36
|
+
|
37
|
+
define_method(name) do
|
38
|
+
path = @_store_path + [name]
|
39
|
+
result = Redux.fetch_by_path(*path)
|
40
|
+
if result
|
41
|
+
result
|
42
|
+
elsif !@_default_proc
|
43
|
+
@_default
|
44
|
+
else
|
45
|
+
@_default_proc.call(self, name)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
define_method("#{name}=") do |val|
|
50
|
+
_validate_attribute(name, val) if @_validate_attributes
|
51
|
+
_update_attribute(name, val)
|
52
|
+
val
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def initialize(key:, revision: nil, attributes: nil)
|
58
|
+
@key = key.to_s
|
59
|
+
@class_name = self.class.name
|
60
|
+
@class_name = @class_name.split('>::').last if @class_name.start_with?('#<')
|
61
|
+
@_store_path = [:data_state, @class_name, @key]
|
62
|
+
@_changed_store_path = [:data_state, :changed, @class_name, @key]
|
63
|
+
@_revision_store_path = [:data_state, :revision, @class_name, @key]
|
64
|
+
attributes = {} unless attributes
|
65
|
+
attributes.each { |a,v| _validate_attribute(a, v) }
|
66
|
+
Isomorfeus.store.dispatch(type: 'DATA_LOAD', data: { @class_name => { @key => attributes },
|
67
|
+
changed: { @class_name => { @key => false }},
|
68
|
+
revision: { @class_name => { @key => revision }}})
|
69
|
+
end
|
70
|
+
|
71
|
+
else # RUBY_ENGINE
|
72
|
+
unless base == LucidArango::Document::Base
|
73
|
+
Isomorfeus.add_valid_data_class(base)
|
74
|
+
base.prop :pub_sub_client, default: nil
|
75
|
+
base.prop :current_user, default: Anonymous.new
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module LucidArango
|
2
|
+
module Vertex
|
3
|
+
class Base
|
4
|
+
include LucidArango::Node::Mixin
|
5
|
+
|
6
|
+
if RUBY_ENGINE != 'opal'
|
7
|
+
def self.inherited(base)
|
8
|
+
Isomorfeus.add_valid_data_class(base)
|
9
|
+
base.prop :pub_sub_client, default: nil
|
10
|
+
base.prop :current_user, default: Anonymous.new
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|