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,79 +0,0 @@
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
- end
75
- end
76
- end
77
- end
78
- end
79
- end
@@ -1,11 +0,0 @@
1
- module LucidStorableObject
2
- class Base
3
- include LucidStorableObject::Mixin
4
-
5
- if RUBY_ENGINE != 'opal'
6
- def self.inherited(base)
7
- Isomorfeus.add_valid_data_class(base)
8
- end
9
- end
10
- end
11
- end
@@ -1,158 +0,0 @@
1
- module LucidStorableObject
2
- module Mixin
3
- # TODO on revision conflict
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
-
10
- def to_gid
11
- [@class_name, @props_json]
12
- end
13
-
14
- base.instance_exec do
15
- def on_load_block
16
- @on_load_block
17
- end
18
-
19
- def load_query_block
20
- @load_query_block
21
- end
22
- end
23
-
24
- if RUBY_ENGINE == 'opal'
25
- def initialize(store_path: nil, validated_props: nil)
26
- @props = validated_props
27
- @props_json = @props.to_json if @props
28
- @class_name = self.class.name
29
- @class_name = @class_name.split('>::').last if @class_name.start_with?('#<')
30
- @store_path = store_path ? store_path : [:data_state, :arrays, @class_name, @props_json]
31
- end
32
-
33
- def loaded?
34
- Redux.fetch_by_path(*@store_path) ? true : false
35
- end
36
-
37
- def items
38
- raw_array = Redux.fetch_by_path(*@store_path)
39
- raw_array ? raw_array : []
40
- end
41
-
42
- def method_missing(method_name, *args, &block)
43
- raw_array = Redux.fetch_by_path(*@store_path)
44
- data_array = raw_array ? raw_array : []
45
- data_array.send(method_name, *args, &block)
46
- end
47
-
48
- def to_transport(inline: false)
49
- raw_array = Redux.fetch_by_path(*@store_path)
50
- if inline
51
- { '_inline' => { @props_json => (raw_array ? raw_array : []) }}
52
- else
53
- { 'arrays' => { @class_name => { @props_json => (raw_array ? raw_array : []) }}}
54
- end
55
- end
56
-
57
- base.instance_exec do
58
- def load(props_hash = {})
59
- validate_props(props_hash)
60
- # instance = self.new(validated_props: Isomorfeus::Data::Props.new(props_hash))
61
- self.promise_load(props_hash, instance) unless instance.loaded?
62
- instance
63
- end
64
-
65
- def on_load(&block)
66
- end
67
-
68
- def promise_load(props_hash = {}, instance = nil)
69
- unless instance
70
- validate_props(props_hash)
71
- # instance = self.new(validated_props: Isomorfeus::Data::Props.new(props_hash))
72
- end
73
-
74
- props_json = instance.instance_variable_get(:@props_json)
75
-
76
- Isomorfeus::Transport.promise_send_path('Isomorfeus::Data::Handler::Generic', self.name, props_json).then do |agent|
77
- if agent.processed
78
- agent.result
79
- else
80
- agent.processed = true
81
- if agent.response.key?(:error)
82
- Isomorfeus.raise_error(message: agent.response[:error])
83
- end
84
- Isomorfeus.store.dispatch(type: 'DATA_LOAD', data: agent.full_response[:data])
85
- agent.result = instance
86
- end
87
- end
88
- end
89
-
90
- def load_query; end
91
- end
92
- else # RUBY_ENGINE
93
- unless base == LucidStorableObject::Base
94
- Isomorfeus.add_valid_data_class(base)
95
- end
96
-
97
- def initialize(store_path: nil, validated_props: nil)
98
- @props = validated_props
99
- @props_json = @props.to_json if @props
100
- @loaded = false
101
- @class_name = self.class.name
102
- @class_name = @class_name.split('>::').last if @class_name.start_with?('#<')
103
- end
104
-
105
- def loaded?
106
- @loaded
107
- end
108
-
109
- def [](name)
110
- @data_array[name]
111
- end
112
-
113
- def items
114
- @data_array
115
- end
116
-
117
- def method_missing(method_name, *args, &block)
118
- @data_array.send(method_name, *args, &block)
119
- end
120
-
121
- def to_transport(inline: false)
122
- if inline
123
- { '_inline' => { @props_json => @data_array }}
124
- else
125
- { 'arrays' => { @class_name => { @props_json => @data_array }}}
126
- end
127
- end
128
-
129
- base.instance_exec do
130
- def load(props_hash = {})
131
- validate_props(props_hash)
132
- # instance = self.new(validated_props: Isomorfeus::Data::Props.new(props_hash))
133
- instance.instance_exec do
134
- @data_array = self.class.load_query_block.call(props_hash)
135
- @loaded = true
136
- end
137
- instance
138
- end
139
-
140
- def on_load(&block)
141
- @on_load_block = block
142
- end
143
-
144
- def promise_load(props_hash = {}, instance = nil)
145
- instance = self.load(props_hash)
146
- result_promise = Promise.new
147
- result_promise.resolve(instance)
148
- result_promise
149
- end
150
-
151
- def load_query(&block)
152
- @load_query_block = block
153
- end
154
- end
155
- end # RUBY_ENGINE
156
- end
157
- end
158
- end
@@ -1,11 +0,0 @@
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
- end
9
- end
10
- end
11
- end
@@ -1,17 +0,0 @@
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
- end
9
- end
10
-
11
- base.include(Enumerable)
12
- base.extend(LucidPropDeclaration::Mixin)
13
- base.extend(Isomorfeus::Data::GenericClassApi)
14
- base.include(Isomorfeus::Data::GenericInstanceApi)
15
- end
16
- end
17
- end
@@ -1,13 +0,0 @@
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
- end
10
- end
11
- end
12
- end
13
- end
@@ -1,9 +0,0 @@
1
- module LucidArango
2
- module Vertex
3
- module Mixin
4
- def self.included(base)
5
- base.include(LucidArango::Node::Mixin)
6
- end
7
- end
8
- end
9
- end