isomorfeus-data 2.0.22 → 2.1.0
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/config.rb +9 -9
- data/lib/isomorfeus/data/document_accelerator.rb +4 -8
- data/lib/isomorfeus/data/handler/generic.rb +22 -22
- data/lib/isomorfeus/data/object_accelerator.rb +9 -8
- data/lib/isomorfeus/data/object_expander.rb +12 -40
- data/lib/isomorfeus/data/version.rb +1 -1
- data/lib/isomorfeus-data.rb +2 -0
- data/lib/isomorfeus_data/lucid_document/mixin.rb +8 -0
- data/lib/isomorfeus_data/lucid_file/mixin.rb +8 -0
- data/lib/isomorfeus_data/lucid_object/mixin.rb +37 -29
- data/lib/isomorfeus_data/lucid_query/mixin.rb +2 -1
- metadata +38 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 336c73e455b2044f1b96dc1a1e2e7a7b9ca0ef962f9121dcd9df9d0e1bea02bb
|
4
|
+
data.tar.gz: 36cd08025344752f7bcac649aabc6e26ecfa85dd00da2135ab4e43f10b3b47e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e97477903e581484d03c93712871671ed56d864f1c7db9379e758c3229913db7c8b08ed8ac33a127ecaf500590f31fbcffcab7cbce7ed97f37c8eb64bab2879b
|
7
|
+
data.tar.gz: 05c46807e85b6403e47b34359fb90cb71f0c8b0b14ddb03973891e985cc83f310544a58f78f85204e462ff41c4a1f8114e2b36e0de0631b024e0b6dcab167f79
|
@@ -56,7 +56,7 @@ module Isomorfeus
|
|
56
56
|
valid_file_classes[raw_class_name(klass)] = true
|
57
57
|
end
|
58
58
|
|
59
|
-
attr_accessor :
|
59
|
+
attr_accessor :storage_path
|
60
60
|
attr_accessor :files_path
|
61
61
|
|
62
62
|
attr_accessor :ferret_path
|
@@ -64,23 +64,23 @@ module Isomorfeus
|
|
64
64
|
|
65
65
|
attr_accessor :hamster_path
|
66
66
|
attr_accessor :hamster_mapsize
|
67
|
-
attr_accessor :
|
68
|
-
attr_accessor :
|
67
|
+
attr_accessor :data_object_envs_path
|
68
|
+
attr_accessor :data_object_idxs_path
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
72
|
if RUBY_ENGINE != 'opal'
|
73
|
-
self.
|
74
|
-
self.files_path = File.expand_path(File.join(self.
|
73
|
+
self.storage_path = File.expand_path(File.join(Isomorfeus.root, 'storage', Isomorfeus.env))
|
74
|
+
self.files_path = File.expand_path(File.join(self.storage_path, 'files'))
|
75
75
|
|
76
76
|
# documents and indices
|
77
|
-
self.ferret_path = File.expand_path(File.join(self.
|
77
|
+
self.ferret_path = File.expand_path(File.join(self.storage_path, 'ferret'))
|
78
78
|
self.data_documents_path = File.expand_path(File.join(self.ferret_path, 'documents'))
|
79
79
|
|
80
80
|
# objects, nodes and edges
|
81
|
-
self.hamster_path = File.expand_path(File.join(self.
|
81
|
+
self.hamster_path = File.expand_path(File.join(self.storage_path, 'hamster'))
|
82
82
|
self.hamster_mapsize = 4294967296
|
83
|
-
self.
|
84
|
-
self.
|
83
|
+
self.data_object_envs_path = File.expand_path(File.join(self.hamster_path, 'object_envs'))
|
84
|
+
self.data_object_idxs_path = File.expand_path(File.join(self.hamster_path, 'object_idxs'))
|
85
85
|
end
|
86
86
|
end
|
@@ -5,17 +5,17 @@ module Isomorfeus
|
|
5
5
|
proc { fer_acc.close_index }
|
6
6
|
end
|
7
7
|
|
8
|
-
attr_reader :doc_class, :doc_class_name
|
8
|
+
attr_reader :doc_class, :doc_class_name
|
9
9
|
attr_accessor :index
|
10
10
|
|
11
11
|
def initialize(doc_class, &block)
|
12
12
|
@doc_class = doc_class
|
13
13
|
@doc_class_name = doc_class.name
|
14
|
-
@doc_class_name_u = @doc_class_name.underscore
|
15
14
|
if block_given?
|
16
15
|
res = block.call(self)
|
17
16
|
@index = res unless @index
|
18
17
|
else
|
18
|
+
@index_path = File.expand_path(File.join(Isomorfeus.data_documents_path, @doc_class_name.underscore))
|
19
19
|
open_index
|
20
20
|
end
|
21
21
|
ObjectSpace.define_finalizer(self, self.class.finalize(self))
|
@@ -23,7 +23,7 @@ module Isomorfeus
|
|
23
23
|
|
24
24
|
def destroy_index
|
25
25
|
close_index
|
26
|
-
FileUtils.rm_rf(index_path
|
26
|
+
FileUtils.rm_rf(@index_path)
|
27
27
|
end
|
28
28
|
|
29
29
|
def close_index
|
@@ -66,14 +66,10 @@ module Isomorfeus
|
|
66
66
|
id = top_docs.hits[0].doc if top_docs.total_hits == 1
|
67
67
|
end
|
68
68
|
|
69
|
-
def index_path
|
70
|
-
File.expand_path(File.join(Isomorfeus.data_documents_path, @doc_class_name_u))
|
71
|
-
end
|
72
|
-
|
73
69
|
def open_index
|
74
70
|
FileUtils.mkdir_p(Isomorfeus.data_documents_path) unless Dir.exist?(Isomorfeus.data_documents_path)
|
75
71
|
field_infos = Isomorfeus::Ferret::Index::FieldInfos.new(store: :yes, index: :yes, term_vector: :with_positions_offsets)
|
76
|
-
@index = Isomorfeus::Ferret::Index::Index.new(path: index_path, key: :key, auto_flush: true, lock_retry_time: 5, field_infos: field_infos)
|
72
|
+
@index = Isomorfeus::Ferret::Index::Index.new(path: @index_path, key: :key, auto_flush: true, lock_retry_time: 5, field_infos: field_infos)
|
77
73
|
@index.field_infos.add_field(:key, store: :yes, index: :yes, term_vector: :no) unless @index.field_infos[:key]
|
78
74
|
@doc_class.field_options.each do |field, options|
|
79
75
|
@index.field_infos.add_field(field, options) unless @index.field_infos[field]
|
@@ -19,7 +19,7 @@ module Isomorfeus
|
|
19
19
|
response_agent.request[type_class_name].each_key do |action|
|
20
20
|
case action
|
21
21
|
when 'load' then process_load(response_agent, type_class, type_class_name)
|
22
|
-
when '
|
22
|
+
when 'execute' then process_execute(response_agent, type_class, type_class_name)
|
23
23
|
when 'create' then process_create(response_agent, type_class, type_class_name)
|
24
24
|
when 'save' then process_save(response_agent, type_class, type_class_name)
|
25
25
|
when 'destroy' then process_destroy(response_agent, type_class, type_class_name)
|
@@ -40,7 +40,7 @@ module Isomorfeus
|
|
40
40
|
data = response_agent.request[type_class_name]['create']
|
41
41
|
instance_data = data['instance']
|
42
42
|
included_items_data = data.key?('included_items') ? data['included_items'] : nil
|
43
|
-
if Isomorfeus.current_user.authorized?(type_class, :create,
|
43
|
+
if Isomorfeus.current_user.authorized?(type_class, :create, type_class.props_from_data(instance_data))
|
44
44
|
instance = type_class.instance_from_transport(instance_data, included_items_data)
|
45
45
|
created_type = instance.create
|
46
46
|
if created_type
|
@@ -56,6 +56,25 @@ module Isomorfeus
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
+
def process_execute(response_agent, type_class, type_class_name)
|
60
|
+
# 'Isomorfeus::Data::Handler::Generic', self.name, :execute, props_json
|
61
|
+
props = response_agent.request[type_class_name]['execute']
|
62
|
+
props.transform_keys!(&:to_sym)
|
63
|
+
if Isomorfeus.current_user.authorized?(type_class, :execute, props)
|
64
|
+
queried_type = type_class.execute(**props)
|
65
|
+
if queried_type
|
66
|
+
response_agent.outer_result = {} unless response_agent.outer_result
|
67
|
+
response_agent.outer_result.deep_merge!(data: queried_type.to_transport)
|
68
|
+
if queried_type.respond_to?(:included_items_to_transport)
|
69
|
+
response_agent.outer_result.deep_merge!(data: queried_type.included_items_to_transport)
|
70
|
+
end
|
71
|
+
response_agent.agent_result = { success: 'ok' }
|
72
|
+
else response_agent.error = { error: { type_class_name => 'Query returned nothing!' }}
|
73
|
+
end
|
74
|
+
else response_agent.error = { error: 'Access denied!' }
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
59
78
|
def process_load(response_agent, type_class, type_class_name)
|
60
79
|
# 'Isomorfeus::Data::Handler::Generic', self.name, :load, key: key
|
61
80
|
props = response_agent.request[type_class_name]['load']
|
@@ -75,31 +94,12 @@ module Isomorfeus
|
|
75
94
|
end
|
76
95
|
end
|
77
96
|
|
78
|
-
def process_query(response_agent, type_class, type_class_name)
|
79
|
-
# 'Isomorfeus::Data::Handler::Generic', self.name, :query, props_json
|
80
|
-
props = response_agent.request[type_class_name]['query']
|
81
|
-
props.transform_keys!(&:to_sym)
|
82
|
-
if Isomorfeus.current_user.authorized?(type_class, :query, props)
|
83
|
-
queried_type = type_class.execute(**props)
|
84
|
-
if queried_type
|
85
|
-
response_agent.outer_result = {} unless response_agent.outer_result
|
86
|
-
response_agent.outer_result.deep_merge!(data: queried_type.to_transport)
|
87
|
-
if queried_type.respond_to?(:included_items_to_transport)
|
88
|
-
response_agent.outer_result.deep_merge!(data: queried_type.included_items_to_transport)
|
89
|
-
end
|
90
|
-
response_agent.agent_result = { success: 'ok' }
|
91
|
-
else response_agent.error = { error: { type_class_name => 'Query returned nothing!' }}
|
92
|
-
end
|
93
|
-
else response_agent.error = { error: 'Access denied!' }
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
97
|
def process_save(response_agent, type_class, type_class_name)
|
98
98
|
# 'Isomorfeus::Data::Handler::Generic', self.name, :save, data_hash
|
99
99
|
data = response_agent.request[type_class_name]['save']
|
100
100
|
instance_data = data['instance']
|
101
101
|
included_items_data = data.key?('included_items') ? data['included_items'] : nil
|
102
|
-
if Isomorfeus.current_user.authorized?(type_class, :save,
|
102
|
+
if Isomorfeus.current_user.authorized?(type_class, :save, type_class.props_from_data(instance_data))
|
103
103
|
instance = type_class.instance_from_transport(instance_data, included_items_data)
|
104
104
|
saved_type = instance.save
|
105
105
|
if saved_type
|
@@ -7,11 +7,12 @@ module Isomorfeus
|
|
7
7
|
|
8
8
|
attr_accessor :index
|
9
9
|
|
10
|
-
def initialize(&block)
|
10
|
+
def initialize(object_class_name, &block)
|
11
11
|
if block_given?
|
12
12
|
res = block.call(self)
|
13
13
|
@index = res unless @index
|
14
14
|
else
|
15
|
+
@index_path = File.expand_path(File.join(Isomorfeus.data_object_idxs_path, object_class_name.underscore))
|
15
16
|
open_index
|
16
17
|
end
|
17
18
|
ObjectSpace.define_finalizer(self, self.class.finalize(self))
|
@@ -19,7 +20,7 @@ module Isomorfeus
|
|
19
20
|
|
20
21
|
def destroy_index
|
21
22
|
close_index
|
22
|
-
FileUtils.rm_rf(
|
23
|
+
FileUtils.rm_rf(@index_path)
|
23
24
|
end
|
24
25
|
|
25
26
|
def close_index
|
@@ -63,12 +64,12 @@ module Isomorfeus
|
|
63
64
|
end
|
64
65
|
|
65
66
|
def open_index
|
66
|
-
FileUtils.mkdir_p(
|
67
|
-
@index = Isomorfeus::Ferret::Index::Index.new(path:
|
68
|
-
@index.field_infos.add_field(:attribute, store: :no, term_vector: :no) unless index.field_infos[:attribute]
|
69
|
-
@index.field_infos.add_field(:class_name, store: :no, term_vector: :no) unless index.field_infos[:class_name]
|
70
|
-
@index.field_infos.add_field(:value, store: :no) unless index.field_infos[:value]
|
71
|
-
@index.field_infos.add_field(:sid_s_attr, store: :yes, term_vector: :no) unless index.field_infos[:sid_s_attr]
|
67
|
+
FileUtils.mkdir_p(@index_path) unless Dir.exist?(@index_path)
|
68
|
+
@index = Isomorfeus::Ferret::Index::Index.new(path: @index_path, key: :sid_s_attr, auto_flush: true, lock_retry_time: 5)
|
69
|
+
@index.field_infos.add_field(:attribute, store: :no, term_vector: :no) unless @index.field_infos[:attribute]
|
70
|
+
@index.field_infos.add_field(:class_name, store: :no, term_vector: :no) unless @index.field_infos[:class_name]
|
71
|
+
@index.field_infos.add_field(:value, store: :no) unless @index.field_infos[:value]
|
72
|
+
@index.field_infos.add_field(:sid_s_attr, store: :yes, term_vector: :no) unless @index.field_infos[:sid_s_attr]
|
72
73
|
end
|
73
74
|
end
|
74
75
|
end
|
@@ -2,51 +2,25 @@ module Isomorfeus
|
|
2
2
|
module Data
|
3
3
|
class ObjectExpander
|
4
4
|
class << self
|
5
|
-
def
|
6
|
-
|
7
|
-
end
|
8
|
-
|
9
|
-
def environment=(env)
|
10
|
-
@environment = env
|
11
|
-
end
|
12
|
-
|
13
|
-
def ref
|
14
|
-
@ref ||= 0
|
15
|
-
end
|
16
|
-
|
17
|
-
def ref=(val)
|
18
|
-
@ref = val
|
19
|
-
end
|
20
|
-
|
21
|
-
def refa
|
22
|
-
self.ref += 1
|
23
|
-
end
|
24
|
-
|
25
|
-
def refs
|
26
|
-
self.ref -= 1 if self.ref > 0
|
27
|
-
end
|
28
|
-
|
29
|
-
def finalize(cls)
|
30
|
-
proc do
|
31
|
-
cls.refs
|
32
|
-
if cls.ref == 0
|
33
|
-
cls.environment.close rescue nil
|
34
|
-
end
|
35
|
-
end
|
5
|
+
def finalize(ins)
|
6
|
+
proc { ins.environment.close rescue nil }
|
36
7
|
end
|
37
8
|
end
|
38
9
|
|
39
|
-
|
10
|
+
attr_accessor :environment
|
11
|
+
|
12
|
+
def initialize(object_class_name, &block)
|
40
13
|
if block_given?
|
41
14
|
res = block.call(self)
|
42
|
-
self.
|
15
|
+
self.environment = res unless self.environment
|
43
16
|
else
|
17
|
+
@env_path = File.expand_path(File.join(Isomorfeus.data_object_envs_path, object_class_name.underscore))
|
44
18
|
open_environment
|
45
19
|
end
|
46
|
-
@db = self.
|
47
|
-
@index_db = self.
|
20
|
+
@db = self.environment.database('objects', create: true)
|
21
|
+
@index_db = self.environment.database('index', create: true, dupsort: true)
|
48
22
|
@use_class_cache = !Isomorfeus.development?
|
49
|
-
ObjectSpace.define_finalizer(self, self.class.finalize(self
|
23
|
+
ObjectSpace.define_finalizer(self, self.class.finalize(self))
|
50
24
|
end
|
51
25
|
|
52
26
|
def create_object(sid_s, obj)
|
@@ -91,10 +65,8 @@ module Isomorfeus
|
|
91
65
|
private
|
92
66
|
|
93
67
|
def open_environment
|
94
|
-
|
95
|
-
|
96
|
-
self.class.environment = Isomorfeus::Hamster.new(Isomorfeus.data_object_env_path, mapsize: Isomorfeus.hamster_mapsize)
|
97
|
-
self.class.refa
|
68
|
+
FileUtils.mkdir_p(@env_path) unless Dir.exist?(@env_path)
|
69
|
+
self.environment = Isomorfeus::Hamster.new(@env_path, mapsize: Isomorfeus.hamster_mapsize)
|
98
70
|
end
|
99
71
|
end
|
100
72
|
end
|
data/lib/isomorfeus-data.rb
CHANGED
@@ -2,7 +2,9 @@ require 'base64'
|
|
2
2
|
require 'stringio'
|
3
3
|
require 'data_uri'
|
4
4
|
require 'securerandom'
|
5
|
+
require 'isomorfeus-policy'
|
5
6
|
require 'isomorfeus-transport'
|
7
|
+
require 'isomorfeus-i18n'
|
6
8
|
require 'isomorfeus/data/config'
|
7
9
|
require 'isomorfeus/data/attribute_support'
|
8
10
|
require 'isomorfeus/data/field_support'
|
@@ -4,6 +4,7 @@ module LucidDocument
|
|
4
4
|
base.include(Isomorfeus::Data::FieldSupport)
|
5
5
|
base.extend(Isomorfeus::Data::GenericClassApi)
|
6
6
|
base.include(Isomorfeus::Data::GenericInstanceApi)
|
7
|
+
base.include(LucidI18n::Mixin)
|
7
8
|
|
8
9
|
base.instance_exec do
|
9
10
|
def escape_string(s)
|
@@ -85,6 +86,13 @@ module LucidDocument
|
|
85
86
|
new(key: key, revision: revision, fields: fields)
|
86
87
|
end
|
87
88
|
|
89
|
+
def props_from_data(instance_data)
|
90
|
+
key = instance_data[self.name].keys.first
|
91
|
+
revision = instance_data[self.name][key].key?('revision') ? instance_data[self.name][key]['revision'] : nil
|
92
|
+
fields = instance_data[self.name][key].key?('fields') ? instance_data[self.name][key]['fields'].transform_keys!(&:to_sym) : nil
|
93
|
+
LucidProps.new({ key: key, revision: revision }.merge!(fields))
|
94
|
+
end
|
95
|
+
|
88
96
|
def setup_index(&block)
|
89
97
|
@_setup_index_block = block
|
90
98
|
end
|
@@ -3,6 +3,7 @@ module LucidFile
|
|
3
3
|
def self.included(base)
|
4
4
|
base.extend(Isomorfeus::Data::GenericClassApi)
|
5
5
|
base.include(Isomorfeus::Data::GenericInstanceApi)
|
6
|
+
base.include(LucidI18n::Mixin)
|
6
7
|
|
7
8
|
def changed!
|
8
9
|
@_changed = true
|
@@ -140,6 +141,13 @@ module LucidFile
|
|
140
141
|
new(key: key, revision: revision, data_uri: data_uri)
|
141
142
|
end
|
142
143
|
|
144
|
+
def props_from_data(instance_data)
|
145
|
+
key = instance_data[self.name].keys.first
|
146
|
+
revision = instance_data[self.name][key].key?('revision') ? instance_data[self.name][key]['revision'] : nil
|
147
|
+
data_uri = instance_data[self.name][key].key?('data_uri') ? instance_data[self.name][key]['data_uri'] : nil
|
148
|
+
LucidProps.new({ key: key, revision: revision, data_uri: data_uri })
|
149
|
+
end
|
150
|
+
|
143
151
|
def files_path
|
144
152
|
@files_path ||= Isomorfeus.files_path
|
145
153
|
end
|
@@ -4,6 +4,7 @@ module LucidObject
|
|
4
4
|
base.include(Isomorfeus::Data::AttributeSupport)
|
5
5
|
base.extend(Isomorfeus::Data::GenericClassApi)
|
6
6
|
base.include(Isomorfeus::Data::GenericInstanceApi)
|
7
|
+
base.include(LucidI18n::Mixin)
|
7
8
|
|
8
9
|
def [](name)
|
9
10
|
send(name)
|
@@ -79,6 +80,13 @@ module LucidObject
|
|
79
80
|
new(key: key, revision: revision, attributes: attributes)
|
80
81
|
end
|
81
82
|
|
83
|
+
def props_from_data(instance_data)
|
84
|
+
key = instance_data[self.name].keys.first
|
85
|
+
revision = instance_data[self.name][key].key?('revision') ? instance_data[self.name][key]['revision'] : nil
|
86
|
+
attributes = instance_data[self.name][key].key?('attributes') ? instance_data[self.name][key]['attributes'].transform_keys!(&:to_sym) : nil
|
87
|
+
LucidProps.new({ key: key, revision: revision }.merge!(attributes))
|
88
|
+
end
|
89
|
+
|
82
90
|
def setup_environment(&block)
|
83
91
|
@_setup_environment_block = block
|
84
92
|
end
|
@@ -87,21 +95,21 @@ module LucidObject
|
|
87
95
|
@_setup_index_block = block
|
88
96
|
end
|
89
97
|
|
90
|
-
def
|
91
|
-
return @
|
92
|
-
@
|
93
|
-
Isomorfeus::Data::ObjectExpander.new(&@_setup_index_block)
|
98
|
+
def object_expander
|
99
|
+
return @object_expander if @object_expander
|
100
|
+
@object_expander = if @_setup_environment_block
|
101
|
+
Isomorfeus::Data::ObjectExpander.new(self.to_s, &@_setup_index_block)
|
94
102
|
else
|
95
|
-
Isomorfeus::Data::ObjectExpander.new
|
103
|
+
Isomorfeus::Data::ObjectExpander.new(self.to_s)
|
96
104
|
end
|
97
105
|
end
|
98
106
|
|
99
|
-
def
|
100
|
-
return @
|
101
|
-
@
|
102
|
-
Isomorfeus::Data::ObjectAccelerator.new(&@_setup_index_block)
|
107
|
+
def object_accelerator
|
108
|
+
return @object_accelerator if @object_accelerator
|
109
|
+
@object_accelerator = if @_setup_index_block
|
110
|
+
Isomorfeus::Data::ObjectAccelerator.new(self.to_s, &@_setup_index_block)
|
103
111
|
else
|
104
|
-
Isomorfeus::Data::ObjectAccelerator.new
|
112
|
+
Isomorfeus::Data::ObjectAccelerator.new(self.to_s)
|
105
113
|
end
|
106
114
|
end
|
107
115
|
|
@@ -112,8 +120,8 @@ module LucidObject
|
|
112
120
|
if idx_type == :text
|
113
121
|
query = "+value:#{val} +class_name:#{self.name}"
|
114
122
|
query << " +attribute:#{attr}" if attr != '*'
|
115
|
-
self.
|
116
|
-
doc = self.
|
123
|
+
self.object_accelerator.search_each(query, options) do |id|
|
124
|
+
doc = self.object_accelerator.index.doc(id)&.load
|
117
125
|
if doc
|
118
126
|
sid_s = doc[:sid_s_attr].split(':|:')[0]
|
119
127
|
obj = self.load(key: sid_s)
|
@@ -122,13 +130,13 @@ module LucidObject
|
|
122
130
|
end
|
123
131
|
else
|
124
132
|
if val == '*'
|
125
|
-
self.
|
133
|
+
self.object_expander.each do |obj|
|
126
134
|
objs << obj if obj.class == self
|
127
135
|
end
|
128
136
|
else
|
129
137
|
attr_s = ":[#{attr}]"
|
130
138
|
accept_all_attr = attr_s == ":[*]" ? true : false
|
131
|
-
self.
|
139
|
+
self.object_expander.search(":[#{self.name}]:|:[:#{val}:]:") do |sid_s_attr|
|
132
140
|
if accept_all_attr || sid_s_attr.end_with?(attr_s)
|
133
141
|
sid_s = sid_s_attr.split(':|:[')[0]
|
134
142
|
obj = self.load(key: sid_s)
|
@@ -142,7 +150,7 @@ module LucidObject
|
|
142
150
|
|
143
151
|
execute_create do
|
144
152
|
self.key = SecureRandom.uuid unless self.key
|
145
|
-
self.class.
|
153
|
+
self.class.object_expander.create_object(self.sid_s, self)
|
146
154
|
self.class.indexed_attributes.each do |attr, idx_type|
|
147
155
|
if idx_type == :text
|
148
156
|
self._create_text_indexed_attribute(attr)
|
@@ -156,14 +164,14 @@ module LucidObject
|
|
156
164
|
execute_destroy do |key:|
|
157
165
|
key = key.to_s
|
158
166
|
sid_s = key.start_with?('[') ? key : gen_sid_s(key)
|
159
|
-
self.
|
167
|
+
self.object_expander.destroy_object(sid_s)
|
160
168
|
self.indexed_attributes.each do |attr, idx_type|
|
161
169
|
if idx_type == :text
|
162
|
-
self.
|
170
|
+
self.object_accelerator.destroy_doc("#{sid_s}:|:[#{attr}]")
|
163
171
|
else
|
164
|
-
old_val = self.
|
165
|
-
self.
|
166
|
-
self.
|
172
|
+
old_val = self.object_expander.index_get("#{sid_s}:|:[#{attr}]")
|
173
|
+
self.object_expander.index_delete("#{sid_s}:|:[#{attr}]", old_val)
|
174
|
+
self.object_expander.index_delete(":[#{self.name}]:|:[:#{old_val}:]:", "#{sid_s}:|:[#{attr}]")
|
167
175
|
end
|
168
176
|
end
|
169
177
|
true
|
@@ -172,12 +180,12 @@ module LucidObject
|
|
172
180
|
execute_load do |key:|
|
173
181
|
key = key.to_s
|
174
182
|
sid_s = key.start_with?('[') ? key : gen_sid_s(key)
|
175
|
-
self.
|
183
|
+
self.object_expander.load_object(sid_s)
|
176
184
|
end
|
177
185
|
|
178
186
|
execute_save do
|
179
187
|
self.key = SecureRandom.uuid unless self.key
|
180
|
-
self.class.
|
188
|
+
self.class.object_expander.save_object(self.sid_s, self)
|
181
189
|
self.class.indexed_attributes.each do |attr, val|
|
182
190
|
if val == :text
|
183
191
|
self._store_text_indexed_attribute(attr)
|
@@ -202,21 +210,21 @@ module LucidObject
|
|
202
210
|
|
203
211
|
def _create_text_indexed_attribute(attr)
|
204
212
|
doc = { sid_s_attr: "#{self.sid_s}:|:[#{attr}]", value: self.send(attr).to_s, attribute: attr.to_s, class_name: @class_name }
|
205
|
-
self.class.
|
213
|
+
self.class.object_accelerator.create_doc(doc)
|
206
214
|
end
|
207
215
|
|
208
216
|
def _store_text_indexed_attribute(attr)
|
209
217
|
doc = { sid_s_attr: "#{self.sid_s}:|:[#{attr}]", value: self.send(attr).to_s, attribute: attr.to_s, class_name: @class_name }
|
210
|
-
self.class.
|
218
|
+
self.class.object_accelerator.save_doc("#{self.sid_s}:|:[#{attr}]", doc)
|
211
219
|
end
|
212
220
|
|
213
221
|
def _store_value_indexed_attribute(attr)
|
214
|
-
old_val = self.class.
|
215
|
-
self.class.
|
216
|
-
self.class.
|
222
|
+
old_val = self.class.object_expander.index_get("#{self.sid_s}:|:[#{attr}]")
|
223
|
+
self.class.object_expander.index_delete("#{self.sid_s}:|:[#{attr}]", old_val)
|
224
|
+
self.class.object_expander.index_delete(":[#{self.class.name}]:|:[:#{old_val}:]:", "#{self.sid_s}:|:[#{attr}]")
|
217
225
|
val = "#{self.send(attr)}"[0..300]
|
218
|
-
self.class.
|
219
|
-
self.class.
|
226
|
+
self.class.object_expander.index_put("#{self.sid_s}:|:[#{attr}]", val)
|
227
|
+
self.class.object_expander.index_put(":[#{self.class.name}]:|:[:#{val}:]:", "#{self.sid_s}:|:[#{attr}]")
|
220
228
|
end
|
221
229
|
|
222
230
|
def _unchange!
|
@@ -2,6 +2,7 @@ module LucidQuery
|
|
2
2
|
module Mixin
|
3
3
|
def self.included(base)
|
4
4
|
base.extend(LucidPropDeclaration::Mixin)
|
5
|
+
base.include(LucidI18n::Mixin)
|
5
6
|
|
6
7
|
if RUBY_ENGINE == 'opal'
|
7
8
|
base.instance_exec do
|
@@ -22,7 +23,7 @@ module LucidQuery
|
|
22
23
|
end
|
23
24
|
props = validated_props(props)
|
24
25
|
props[:key] = query_result_instance.key
|
25
|
-
Isomorfeus::Transport.promise_send_path( 'Isomorfeus::Data::Handler::Generic', self.name, :
|
26
|
+
Isomorfeus::Transport.promise_send_path( 'Isomorfeus::Data::Handler::Generic', self.name, :execute, props).then do |agent|
|
26
27
|
agent.process do
|
27
28
|
query_result_instance._load_from_store!
|
28
29
|
Isomorfeus.store.dispatch(type: 'DATA_LOAD', data: agent.full_response[:data])
|
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: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Biedermann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-02-
|
11
|
+
date: 2022-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.14.
|
75
|
+
version: 0.14.10
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.14.
|
82
|
+
version: 0.14.10
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: isomorfeus-ferret
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,20 +108,48 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 0.6.4
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: isomorfeus-i18n
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 2.1.0
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 2.1.0
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: isomorfeus-policy
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 2.1.0
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 2.1.0
|
111
139
|
- !ruby/object:Gem::Dependency
|
112
140
|
name: isomorfeus-preact
|
113
141
|
requirement: !ruby/object:Gem::Requirement
|
114
142
|
requirements:
|
115
143
|
- - "~>"
|
116
144
|
- !ruby/object:Gem::Version
|
117
|
-
version: 10.6.
|
145
|
+
version: 10.6.34
|
118
146
|
type: :runtime
|
119
147
|
prerelease: false
|
120
148
|
version_requirements: !ruby/object:Gem::Requirement
|
121
149
|
requirements:
|
122
150
|
- - "~>"
|
123
151
|
- !ruby/object:Gem::Version
|
124
|
-
version: 10.6.
|
152
|
+
version: 10.6.34
|
125
153
|
- !ruby/object:Gem::Dependency
|
126
154
|
name: isomorfeus-redux
|
127
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,28 +170,28 @@ dependencies:
|
|
142
170
|
requirements:
|
143
171
|
- - '='
|
144
172
|
- !ruby/object:Gem::Version
|
145
|
-
version: 2.0
|
173
|
+
version: 2.1.0
|
146
174
|
type: :runtime
|
147
175
|
prerelease: false
|
148
176
|
version_requirements: !ruby/object:Gem::Requirement
|
149
177
|
requirements:
|
150
178
|
- - '='
|
151
179
|
- !ruby/object:Gem::Version
|
152
|
-
version: 2.0
|
180
|
+
version: 2.1.0
|
153
181
|
- !ruby/object:Gem::Dependency
|
154
182
|
name: isomorfeus
|
155
183
|
requirement: !ruby/object:Gem::Requirement
|
156
184
|
requirements:
|
157
185
|
- - '='
|
158
186
|
- !ruby/object:Gem::Version
|
159
|
-
version: 2.0
|
187
|
+
version: 2.1.0
|
160
188
|
type: :development
|
161
189
|
prerelease: false
|
162
190
|
version_requirements: !ruby/object:Gem::Requirement
|
163
191
|
requirements:
|
164
192
|
- - '='
|
165
193
|
- !ruby/object:Gem::Version
|
166
|
-
version: 2.0
|
194
|
+
version: 2.1.0
|
167
195
|
- !ruby/object:Gem::Dependency
|
168
196
|
name: rake
|
169
197
|
requirement: !ruby/object:Gem::Requirement
|