apiql 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/apiql.gemspec +1 -1
- data/lib/apiql.rb +19 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be1cd2e607d5b0b9f400d217c227a53826f20e5904db4caef949978580be45cf
|
4
|
+
data.tar.gz: cbd052428a30d779a3ab3670ca60eebf15fe095df867a7f3d3f1d19c35b7663d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b583b6f640c5113d3735d90358375d20cd702382b9ca6815d85a70a15473ccac3ce683cd029fe3abcb7c0e812521ff800c4c7ca3291864939592225095449723
|
7
|
+
data.tar.gz: 7c6090d8ab1e9ea06a181ed7c397cea36c4f6bbd0849f55f45f03fbe1506de24c06ea9a1ad3aebd8959189bd3c3ed9547434eeb56d44a0552e907fcbb1dca124
|
data/apiql.gemspec
CHANGED
data/lib/apiql.rb
CHANGED
@@ -7,6 +7,13 @@ class APIQL
|
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
+
class ::Hash
|
11
|
+
def deep_merge(second)
|
12
|
+
merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : Array === v1 && Array === v2 ? v1 | v2 : [:undefined, nil, :nil].include?(v2) ? v1 : v2 }
|
13
|
+
self.merge(second.to_h, &merger)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
10
17
|
module CRUD
|
11
18
|
def model(klass)
|
12
19
|
define_method "#{klass.name.pluralize.underscore}" do |page = nil, page_size = 10|
|
@@ -233,7 +240,9 @@ class APIQL
|
|
233
240
|
end
|
234
241
|
end
|
235
242
|
|
236
|
-
result
|
243
|
+
result = result.deep_merge({
|
244
|
+
name => @context.render_value(data, sub_schema)
|
245
|
+
})
|
237
246
|
end
|
238
247
|
else
|
239
248
|
reg = call.match(/\A((?<alias>[\w\.]+):\s*)?(?<name>[\w\.]+)(\((?<params>.*?)\))?\z/)
|
@@ -253,7 +262,9 @@ class APIQL
|
|
253
262
|
data = nil
|
254
263
|
end
|
255
264
|
|
256
|
-
result
|
265
|
+
result = result.deep_merge({
|
266
|
+
name => data
|
267
|
+
})
|
257
268
|
end
|
258
269
|
end
|
259
270
|
|
@@ -306,13 +317,17 @@ class APIQL
|
|
306
317
|
reg = field.match(/\A(?<name>[\w\.]+)(\((?<params>.*?)\))?\z/)
|
307
318
|
raise Error, field unless reg.present?
|
308
319
|
|
309
|
-
respond
|
320
|
+
respond = respond.deep_merge({
|
321
|
+
reg[:name] => render_attribute(reg[:name], reg[:params].presence, sub_schema)
|
322
|
+
})
|
310
323
|
end
|
311
324
|
else
|
312
325
|
reg = field.match(/\A(?<name>[\w\.]+)(\((?<params>.*?)\))?\z/)
|
313
326
|
raise Error, field unless reg.present?
|
314
327
|
|
315
|
-
respond
|
328
|
+
respond = respond.deep_merge({
|
329
|
+
reg[:name] => render_attribute(reg[:name], reg[:params].presence)
|
330
|
+
})
|
316
331
|
end
|
317
332
|
end
|
318
333
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apiql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Silchenko
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|