arangorb3 0.0.12 → 0.0.13

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 72a0a244839e2f1722fca7bcd9bf561dd0a540664cd6f3b851d82f122d89a400
4
- data.tar.gz: 6f3ee6b9172cdc1bb3740cca9169bd8e0fc90ba33f2169d76fdf592d2bf019c0
3
+ metadata.gz: 862751f63bd58e50b0c83eb9e0f49d329071dc9aef8ae3f59a7ab1ce33dc1c29
4
+ data.tar.gz: 8942ef5c1c6bcc52de3948b7eab7f7ae969f31e06ca1269b439198691fb13eb3
5
5
  SHA512:
6
- metadata.gz: b61dd5e4fd01390d14705aff04f6e3a47f11d0546ed4109d221550cd91208ce5f760f21ea1cf4e4cff25ae0965fbec2da8effda7f9d2a3ab2b6596d4f09d9ade
7
- data.tar.gz: 9972a1bab265999a749be0b3cc17cd094c159df0d35ae6fea773cc99c2d094f6b9807c357d564822298b8e88aa2a46a48b9a564cfa235aec0a0510e9a68ef6be
6
+ metadata.gz: cdd755bdcb7b1906fa0b512789af7a4bb4649dfdc06565de06dfe297638c5954021b30307fb4297e5ae8b1a0269be11e9822c9219ad42a3758da7d75ca63496d
7
+ data.tar.gz: 5c7e375b0c52cf58d726765bd849bedeb6a9564b3461d0c16bb59e71fe1d1c368b319e8206e5aeda43011240bb7117b036642f5dbe8044394a3fe76a9d0a6fd3
data/ArangoRB.gemspec CHANGED
@@ -4,7 +4,7 @@ require "rake"
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = 'arangorb3'
7
- s.version = '0.0.12'
7
+ s.version = '0.0.13'
8
8
  s.authors = ['Vishal Singh']
9
9
  s.email = ['vishalpundir49@gmail.com']
10
10
  s.homepage = 'https://github.com/vishalsingh123/ArangoRB'
data/lib/Collection.rb CHANGED
@@ -6,24 +6,49 @@ module Arango
6
6
  include Arango::Helper_Return
7
7
  include Arango::Database_Return
8
8
 
9
- def self.new(*args)
10
- hash = args[0]
11
- super unless hash.is_a?(Hash)
9
+ # def self.new(*args)
10
+ # hash = args[0]
11
+ # super unless hash.is_a?(Hash)
12
+ # database = hash[:database]
13
+ # if database.is_a?(Arango::Database) && database.server.active_cache
14
+ # cache_name = "#{database.name}/#{hash[:name]}"
15
+ # cached = database.server.cache.cache.dig(:database, cache_name)
16
+ # if cached.nil?
17
+ # hash[:cache_name] = cache_name
18
+ # return super
19
+ # else
20
+ # body = hash[:body] || {}
21
+ # [:type, :isSystem].each{|k| body[k] ||= hash[k]}
22
+ # cached.assign_attributes(body)
23
+ # return cached
24
+ # end
25
+ # end
26
+ # super
27
+ # end
28
+
29
+ def self.new(*args, **kwargs)
30
+ hash = args[0] || kwargs
31
+ unless hash.is_a?(Hash)
32
+ return super(*args, **kwargs)
33
+ end
34
+
12
35
  database = hash[:database]
13
36
  if database.is_a?(Arango::Database) && database.server.active_cache
14
37
  cache_name = "#{database.name}/#{hash[:name]}"
15
38
  cached = database.server.cache.cache.dig(:database, cache_name)
39
+
16
40
  if cached.nil?
17
41
  hash[:cache_name] = cache_name
18
- return super
42
+ return super(**hash)
19
43
  else
20
44
  body = hash[:body] || {}
21
- [:type, :isSystem].each{|k| body[k] ||= hash[k]}
45
+ [:type, :isSystem].each { |k| body[k] ||= hash[k] }
22
46
  cached.assign_attributes(body)
23
47
  return cached
24
48
  end
25
49
  end
26
- super
50
+
51
+ super(**hash)
27
52
  end
28
53
 
29
54
  def initialize(name:, database:, graph: nil, body: {}, type: :document,
data/lib/Database.rb CHANGED
@@ -6,21 +6,42 @@ module Arango
6
6
  include Arango::Helper_Return
7
7
  include Arango::Server_Return
8
8
 
9
- def self.new(*args)
10
- hash = args[0]
11
- super unless hash.is_a?(Hash)
9
+ # def self.new(*args)
10
+ # hash = args[0]
11
+ # super unless hash.is_a?(Hash)
12
+ # server = hash[:server]
13
+ # if server.is_a?(Arango::Server) && server.active_cache
14
+ # cache_name = hash[:name]
15
+ # cached = server.cache.cache.dig(:database, cache_name)
16
+ # if cached.nil?
17
+ # hash[:cache_name] = cache_name
18
+ # return super
19
+ # else
20
+ # return cached
21
+ # end
22
+ # end
23
+ # super
24
+ # end
25
+ def self.new(*args, **kwargs)
26
+ hash = args[0] || kwargs
27
+ unless hash.is_a?(Hash)
28
+ return super(*args, **kwargs)
29
+ end
30
+
12
31
  server = hash[:server]
32
+
13
33
  if server.is_a?(Arango::Server) && server.active_cache
14
34
  cache_name = hash[:name]
15
35
  cached = server.cache.cache.dig(:database, cache_name)
16
36
  if cached.nil?
17
37
  hash[:cache_name] = cache_name
18
- return super
38
+ return super(**hash)
19
39
  else
20
40
  return cached
21
41
  end
22
42
  end
23
- super
43
+
44
+ super(**hash)
24
45
  end
25
46
 
26
47
  def initialize(name:, server:, cache_name: nil)
data/lib/Document.rb CHANGED
@@ -6,27 +6,57 @@ module Arango
6
6
  include Arango::Helper_Return
7
7
  include Arango::Collection_Return
8
8
 
9
- def self.new(*args)
10
- hash = args[0]
11
- super unless hash.is_a?(Hash)
12
- collection = hash[:collection]
13
- if collection.is_a?(Arango::Collection) &&
14
- collection.database.server.active_cache && !hash[:name].nil?
15
- cache_name = "#{collection.database.name}/#{collection.name}/#{hash[:name]}"
16
- cached = collection.database.server.cache.cache.dig(:document, cache_name)
17
- if cached.nil?
18
- hash[:cache_name] = cache_name
19
- return super
20
- else
21
- body = hash[:body] || {}
22
- [:rev, :from, :to].each{|k| body[:"_#{k}"] ||= hash[k]}
23
- body[:"_key"] ||= hash[:name]
24
- cached.assign_attributes(body)
25
- return cached
26
- end
27
- end
28
- super
29
- end
9
+ # def self.new(*args)
10
+ # hash = args[0]
11
+ # super unless hash.is_a?(Hash)
12
+ # collection = hash[:collection]
13
+ # if collection.is_a?(Arango::Collection) &&
14
+ # collection.database.server.active_cache && !hash[:name].nil?
15
+ # cache_name = "#{collection.database.name}/#{collection.name}/#{hash[:name]}"
16
+ # cached = collection.database.server.cache.cache.dig(:document, cache_name)
17
+ # if cached.nil?
18
+ # hash[:cache_name] = cache_name
19
+ # return super
20
+ # else
21
+ # body = hash[:body] || {}
22
+ # [:rev, :from, :to].each{|k| body[:"_#{k}"] ||= hash[k]}
23
+ # body[:"_key"] ||= hash[:name]
24
+ # cached.assign_attributes(body)
25
+ # return cached
26
+ # end
27
+ # end
28
+ # super
29
+ # end
30
+
31
+ def self.new(hash)
32
+ unless hash.is_a?(Hash)
33
+ return super
34
+ end
35
+
36
+ collection = hash[:collection]
37
+
38
+ if collection.is_a?(Arango::Collection) &&
39
+ collection.database.server.active_cache &&
40
+ hash[:name]
41
+
42
+ cache_name = "#{collection.database.name}/#{collection.name}/#{hash[:name]}"
43
+ cached = collection.database.server.cache.cache.dig(:document, cache_name)
44
+
45
+ if cached.nil?
46
+ hash[:cache_name] = cache_name
47
+ return super(**hash)
48
+ else
49
+ body = hash[:body] || {}
50
+ [:rev, :from, :to].each { |k| body[:"_#{k}"] ||= hash[k] }
51
+ body[:"_key"] ||= hash[:name]
52
+ cached.assign_attributes(body)
53
+ return cached
54
+ end
55
+ end
56
+
57
+ super(**hash)
58
+ end
59
+
30
60
 
31
61
  def initialize(name: nil, collection:, body: {}, rev: nil, from: nil,
32
62
  to: nil, cache_name: nil)
data/lib/Foxx.rb CHANGED
@@ -6,26 +6,55 @@ module Arango
6
6
  include Arango::Helper_Return
7
7
  include Arango::Database_Return
8
8
 
9
- def self.new(*args)
10
- hash = args[0]
11
- super unless hash.is_a?(Hash)
12
- database = hash[:database]
13
- if database.is_a?(Arango::Database) && database.server.active_cache && !hash[:mount].nil?
14
- cache_name = "#{database.name}/#{hash[:mount]}"
15
- cached = database.server.cache.cache.dig(:foxx, cache_name)
16
- if cached.nil?
17
- hash[:cache_name] = cache_name
18
- return super
19
- else
20
- body = hash[:body] || {}
21
- [:mount, :development, :legacy, :provides, :name, :version,
22
- :type, :setup, :teardown].each{|k| body[k] ||= hash[k]}
23
- cached.assign_attributes(body)
24
- return cached
25
- end
26
- end
27
- super
28
- end
9
+ # def self.new(*args)
10
+ # hash = args[0]
11
+ # super unless hash.is_a?(Hash)
12
+ # database = hash[:database]
13
+ # if database.is_a?(Arango::Database) && database.server.active_cache && !hash[:mount].nil?
14
+ # cache_name = "#{database.name}/#{hash[:mount]}"
15
+ # cached = database.server.cache.cache.dig(:foxx, cache_name)
16
+ # if cached.nil?
17
+ # hash[:cache_name] = cache_name
18
+ # return super
19
+ # else
20
+ # body = hash[:body] || {}
21
+ # [:mount, :development, :legacy, :provides, :name, :version,
22
+ # :type, :setup, :teardown].each{|k| body[k] ||= hash[k]}
23
+ # cached.assign_attributes(body)
24
+ # return cached
25
+ # end
26
+ # end
27
+ # super
28
+ # end
29
+
30
+ def self.new(hash)
31
+ unless hash.is_a?(Hash)
32
+ return super
33
+ end
34
+
35
+ database = hash[:database]
36
+ if database.is_a?(Arango::Database) && database.server.active_cache && !hash[:mount].nil?
37
+ cache_name = "#{database.name}/#{hash[:mount]}"
38
+ cached = database.server.cache.cache.dig(:foxx, cache_name)
39
+
40
+ if cached.nil?
41
+ hash[:cache_name] = cache_name
42
+ return super(hash)
43
+ else
44
+ body = hash[:body] || {}
45
+ [
46
+ :mount, :development, :legacy, :provides, :name, :version,
47
+ :type, :setup, :teardown
48
+ ].each { |k| body[k] ||= hash[k] }
49
+
50
+ cached.assign_attributes(body)
51
+ return cached
52
+ end
53
+ end
54
+
55
+ super(hash)
56
+ end
57
+
29
58
 
30
59
  def initialize(database:, body: {}, mount:, development: nil, legacy: nil,
31
60
  provides: nil, name: nil, version: nil, type: "application/json",
data/lib/Graph.rb CHANGED
@@ -6,26 +6,54 @@ module Arango
6
6
  include Arango::Helper_Return
7
7
  include Arango::Database_Return
8
8
 
9
- def self.new(*args)
10
- hash = args[0]
11
- super unless hash.is_a?(Hash)
12
- database = hash[:database]
13
- if database.is_a?(Arango::Database) && database.server.active_cache
14
- cache_name = "#{database.name}/#{hash[:name]}"
15
- cached = database.server.cache.cache.dig(:graph, cache_name)
16
- if cached.nil?
17
- hash[:cache_name] = cache_name
18
- return super
19
- else
20
- body = hash[:body] || {}
21
- [:isSmart, :edgeDefinitions, :orphanCollections, :numberOfShards,
22
- :replicationFactor, :smartGraphAttribute].each{|k| body[k] ||= hash[k]}
23
- cached.assign_attributes(body)
24
- return cached
25
- end
26
- end
27
- super
28
- end
9
+ # def self.new(*args)
10
+ # hash = args[0]
11
+ # super unless hash.is_a?(Hash)
12
+ # database = hash[:database]
13
+ # if database.is_a?(Arango::Database) && database.server.active_cache
14
+ # cache_name = "#{database.name}/#{hash[:name]}"
15
+ # cached = database.server.cache.cache.dig(:graph, cache_name)
16
+ # if cached.nil?
17
+ # hash[:cache_name] = cache_name
18
+ # return super
19
+ # else
20
+ # body = hash[:body] || {}
21
+ # [:isSmart, :edgeDefinitions, :orphanCollections, :numberOfShards,
22
+ # :replicationFactor, :smartGraphAttribute].each{|k| body[k] ||= hash[k]}
23
+ # cached.assign_attributes(body)
24
+ # return cached
25
+ # end
26
+ # end
27
+ # super
28
+ # end
29
+ def self.new(hash)
30
+ unless hash.is_a?(Hash)
31
+ return super
32
+ end
33
+
34
+ database = hash[:database]
35
+ if database.is_a?(Arango::Database) && database.server.active_cache
36
+ cache_name = "#{database.name}/#{hash[:name]}"
37
+ cached = database.server.cache.cache.dig(:graph, cache_name)
38
+
39
+ if cached.nil?
40
+ hash[:cache_name] = cache_name
41
+ return super(hash)
42
+ else
43
+ body = hash[:body] || {}
44
+ [
45
+ :isSmart, :edgeDefinitions, :orphanCollections,
46
+ :numberOfShards, :replicationFactor, :smartGraphAttribute
47
+ ].each { |k| body[k] ||= hash[k] }
48
+
49
+ cached.assign_attributes(body)
50
+ return cached
51
+ end
52
+ end
53
+
54
+ super(hash)
55
+ end
56
+
29
57
 
30
58
  def initialize(name:, database:, edgeDefinitions: [],
31
59
  orphanCollections: [], body: {}, numberOfShards: nil, isSmart: nil,
data/lib/Index.rb CHANGED
@@ -6,26 +6,55 @@ module Arango
6
6
  include Arango::Helper_Return
7
7
  include Arango::Collection_Return
8
8
 
9
- def self.new(*args)
10
- hash = args[0]
11
- super unless hash.is_a?(Hash)
12
- collection = hash[:collection]
13
- if collection.is_a?(Arango::Collection) && collection.database.server.active_cache && !hash[:id].nil?
14
- cache_name = "#{collection.database.name}/#{collection.name}/#{hash[:id]}"
15
- cached = collection.database.server.cache.cache.dig(:index, cache_name)
16
- if cached.nil?
17
- hash[:cache_name] = cache_name
18
- return super
19
- else
20
- body = hash[:body] || {}
21
- [:type, :sparse, :unique, :fields, :deduplicate, :geoJson,
22
- :minLength].each{|k| body[k] ||= hash[k]}
23
- cached.assign_attributes(body)
24
- return cached
25
- end
26
- end
27
- super
28
- end
9
+ # def self.new(*args)
10
+ # hash = args[0]
11
+ # super unless hash.is_a?(Hash)
12
+ # collection = hash[:collection]
13
+ # if collection.is_a?(Arango::Collection) && collection.database.server.active_cache && !hash[:id].nil?
14
+ # cache_name = "#{collection.database.name}/#{collection.name}/#{hash[:id]}"
15
+ # cached = collection.database.server.cache.cache.dig(:index, cache_name)
16
+ # if cached.nil?
17
+ # hash[:cache_name] = cache_name
18
+ # return super
19
+ # else
20
+ # body = hash[:body] || {}
21
+ # [:type, :sparse, :unique, :fields, :deduplicate, :geoJson,
22
+ # :minLength].each{|k| body[k] ||= hash[k]}
23
+ # cached.assign_attributes(body)
24
+ # return cached
25
+ # end
26
+ # end
27
+ # super
28
+ # end
29
+ def self.new(hash)
30
+ unless hash.is_a?(Hash)
31
+ return super
32
+ end
33
+
34
+ collection = hash[:collection]
35
+ if collection.is_a?(Arango::Collection) &&
36
+ collection.database.server.active_cache &&
37
+ !hash[:id].nil?
38
+
39
+ cache_name = "#{collection.database.name}/#{collection.name}/#{hash[:id]}"
40
+ cached = collection.database.server.cache.cache.dig(:index, cache_name)
41
+
42
+ if cached.nil?
43
+ hash[:cache_name] = cache_name
44
+ return super(hash)
45
+ else
46
+ body = hash[:body] || {}
47
+ [:type, :sparse, :unique, :fields, :deduplicate, :geoJson, :minLength].each do |k|
48
+ body[k] ||= hash[k]
49
+ end
50
+ cached.assign_attributes(body)
51
+ return cached
52
+ end
53
+ end
54
+
55
+ super(hash)
56
+ end
57
+
29
58
 
30
59
  def initialize(collection:, body: {}, id: nil, type: "hash", unique: nil,
31
60
  fields:, sparse: nil, geoJson: nil, minLength: nil, deduplicate: nil,
data/lib/Server.rb CHANGED
@@ -154,13 +154,21 @@ module Arango
154
154
 
155
155
  # === REQUESTS ===
156
156
 
157
- def request(*args)
158
- if @pool
159
- @internal_request.with{|request| request.request(*args)}
160
- else
161
- @request.request(*args)
162
- end
163
- end
157
+ # def request(*args)
158
+ # if @pool
159
+ # @internal_request.with{|request| request.request(*args)}
160
+ # else
161
+ # @request.request(*args)
162
+ # end
163
+ # end
164
+
165
+ def request(action, url, **kwargs)
166
+ if @pool
167
+ @internal_request.with { |request| request.request(action, url, **kwargs) }
168
+ else
169
+ @request.request(action, url, **kwargs)
170
+ end
171
+ end
164
172
 
165
173
  def download(*args)
166
174
  if @pool
data/lib/Task.rb CHANGED
@@ -6,24 +6,49 @@ module Arango
6
6
  include Arango::Helper_Return
7
7
  include Arango::Database_Return
8
8
 
9
- def self.new(*args)
10
- hash = args[0]
11
- super unless hash.is_a?(Hash)
12
- database = hash[:database]
13
- if database.is_a?(Arango::Database) && database.server.active_cache && !hash[:id].nil?
14
- cache_name = "#{database.name}/#{hash[:id]}"
15
- cached = database.server.cache.cache.dig(:task, cache_name)
16
- if cached.nil?
17
- hash[:cache_name] = cache_name
18
- return super
19
- else
20
- body = hash[:body] || {}
21
- [:name, :type, :period, :command, :params, :created].each{|k| body[k] ||= hash[k]}
22
- cached.assign_attributes(body)
23
- end
24
- end
25
- super
26
- end
9
+ # def self.new(*args)
10
+ # hash = args[0]
11
+ # super unless hash.is_a?(Hash)
12
+ # database = hash[:database]
13
+ # if database.is_a?(Arango::Database) && database.server.active_cache && !hash[:id].nil?
14
+ # cache_name = "#{database.name}/#{hash[:id]}"
15
+ # cached = database.server.cache.cache.dig(:task, cache_name)
16
+ # if cached.nil?
17
+ # hash[:cache_name] = cache_name
18
+ # return super
19
+ # else
20
+ # body = hash[:body] || {}
21
+ # [:name, :type, :period, :command, :params, :created].each{|k| body[k] ||= hash[k]}
22
+ # cached.assign_attributes(body)
23
+ # end
24
+ # end
25
+ # super
26
+ # end
27
+
28
+ def self.new(hash)
29
+ unless hash.is_a?(Hash)
30
+ return super
31
+ end
32
+
33
+ database = hash[:database]
34
+ if database.is_a?(Arango::Database) && database.server.active_cache && !hash[:id].nil?
35
+ cache_name = "#{database.name}/#{hash[:id]}"
36
+ cached = database.server.cache.cache.dig(:task, cache_name)
37
+
38
+ if cached.nil?
39
+ hash[:cache_name] = cache_name
40
+ return super(hash)
41
+ else
42
+ body = hash[:body] || {}
43
+ [:name, :type, :period, :command, :params, :created].each { |k| body[k] ||= hash[k] }
44
+ cached.assign_attributes(body)
45
+ return cached
46
+ end
47
+ end
48
+
49
+ super(hash)
50
+ end
51
+
27
52
 
28
53
  def initialize(id: nil, name: nil, type: nil, period: nil, command: nil,
29
54
  params: nil, created: nil, body: {}, database:, cache_name: nil)
data/lib/User.rb CHANGED
@@ -6,25 +6,50 @@ module Arango
6
6
  include Arango::Helper_Return
7
7
  include Arango::Server_Return
8
8
 
9
- def self.new(*args)
10
- hash = args[0]
11
- super unless hash.is_a?(Hash)
12
- database = hash[:database]
13
- if database.is_a?(Arango::Database) && database.server.active_cache
14
- cache_name = hash[:name]
15
- cached = database.server.cache.cache.dig(:user, cache_name)
16
- if cached.nil?
17
- hash[:cache_name] = cache_name
18
- return super
19
- else
20
- body = {}
21
- [:password, :extra, :active].each{|k| body[k] ||= hash[k]}
22
- cached.assign_attributes(body)
23
- return cached
24
- end
25
- end
26
- super
27
- end
9
+ # def self.new(*args)
10
+ # hash = args[0]
11
+ # super unless hash.is_a?(Hash)
12
+ # database = hash[:database]
13
+ # if database.is_a?(Arango::Database) && database.server.active_cache
14
+ # cache_name = hash[:name]
15
+ # cached = database.server.cache.cache.dig(:user, cache_name)
16
+ # if cached.nil?
17
+ # hash[:cache_name] = cache_name
18
+ # return super
19
+ # else
20
+ # body = {}
21
+ # [:password, :extra, :active].each{|k| body[k] ||= hash[k]}
22
+ # cached.assign_attributes(body)
23
+ # return cached
24
+ # end
25
+ # end
26
+ # super
27
+ # end
28
+
29
+ def self.new(hash)
30
+ unless hash.is_a?(Hash)
31
+ return super
32
+ end
33
+
34
+ database = hash[:database]
35
+ if database.is_a?(Arango::Database) && database.server.active_cache
36
+ cache_name = hash[:name]
37
+ cached = database.server.cache.cache.dig(:user, cache_name)
38
+
39
+ if cached.nil?
40
+ hash[:cache_name] = cache_name
41
+ return super(hash)
42
+ else
43
+ body = {}
44
+ [:password, :extra, :active].each { |k| body[k] ||= hash[k] }
45
+ cached.assign_attributes(body)
46
+ return cached
47
+ end
48
+ end
49
+
50
+ super(hash)
51
+ end
52
+
28
53
 
29
54
  def initialize(server:, password: "", name:, extra: {}, active: nil, cache_name: nil)
30
55
  assign_server(server)
data/lib/View.rb CHANGED
@@ -6,25 +6,53 @@ module Arango
6
6
  include Arango::Helper_Return
7
7
  include Arango::Database_Return
8
8
 
9
- def self.new(*args)
10
- hash = args[0]
11
- super unless hash.is_a?(Hash)
12
- database = hash[:database]
13
- if database.is_a?(Arango::Database) && database.server.active_cache && !hash[:id].nil?
14
- cache_name = "#{database.name}/#{hash[:id]}"
15
- cached = database.server.cache.cache.dig(:view, cache_name)
16
- if cached.nil?
17
- hash[:cache_name] = cache_name
18
- return super
19
- else
20
- body = {}
21
- [:type, :name].each{|k| body[k] ||= hash[k]}
22
- cached.assign_attributes(body)
23
- return cached
24
- end
25
- end
26
- super
27
- end
9
+ # def self.new(*args)
10
+ # hash = args[0]
11
+ # super unless hash.is_a?(Hash)
12
+ # database = hash[:database]
13
+ # if database.is_a?(Arango::Database) && database.server.active_cache && !hash[:id].nil?
14
+ # cache_name = "#{database.name}/#{hash[:id]}"
15
+ # cached = database.server.cache.cache.dig(:view, cache_name)
16
+ # if cached.nil?
17
+ # hash[:cache_name] = cache_name
18
+ # return super
19
+ # else
20
+ # body = {}
21
+ # [:type, :name].each{|k| body[k] ||= hash[k]}
22
+ # cached.assign_attributes(body)
23
+ # return cached
24
+ # end
25
+ # end
26
+ # super
27
+ # end
28
+
29
+ def self.new(hash)
30
+ unless hash.is_a?(Hash)
31
+ return super
32
+ end
33
+
34
+ database = hash[:database]
35
+ if database.is_a?(Arango::Database) &&
36
+ database.server.active_cache &&
37
+ !hash[:id].nil?
38
+
39
+ cache_name = "#{database.name}/#{hash[:id]}"
40
+ cached = database.server.cache.cache.dig(:view, cache_name)
41
+
42
+ if cached.nil?
43
+ hash[:cache_name] = cache_name
44
+ return super(hash)
45
+ else
46
+ body = {}
47
+ [:type, :name].each { |k| body[k] ||= hash[k] }
48
+ cached.assign_attributes(body)
49
+ return cached
50
+ end
51
+ end
52
+
53
+ super(hash)
54
+ end
55
+
28
56
 
29
57
  def initialize(database:, type: "arangosearch", name:, id: nil, cache_name: nil)
30
58
  assign_database(database)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arangorb3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vishal Singh