apiql 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/apiql.gemspec +1 -1
  3. data/lib/apiql.rb +19 -4
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 07a5e72eaeb35325718dcef5da7e5edb36a15510c08214495657ddbf81e9ad70
4
- data.tar.gz: 4019aa7577844d6b8b4b11c583cd3b908b95272b3b5bbd1f488e0341507d2ffb
3
+ metadata.gz: be1cd2e607d5b0b9f400d217c227a53826f20e5904db4caef949978580be45cf
4
+ data.tar.gz: cbd052428a30d779a3ab3670ca60eebf15fe095df867a7f3d3f1d19c35b7663d
5
5
  SHA512:
6
- metadata.gz: 3473948636742149aba25b20224ac331c762ec1dfa8c5d9ba3297bc0811bfa51293912d4d97d5760d8042dc7989a6b3f8fc83d26e0c46c302abb26c82ab9e5e3
7
- data.tar.gz: c860d4d1a179fae2e0ec6b57b806af5a49cddf66cef385f435bd6397b1a401ee8b00770c89f5b8a17ec428589dacb6be0671edbaaeb5039f90a0d922b8b4fa16
6
+ metadata.gz: b583b6f640c5113d3735d90358375d20cd702382b9ca6815d85a70a15473ccac3ce683cd029fe3abcb7c0e812521ff800c4c7ca3291864939592225095449723
7
+ data.tar.gz: 7c6090d8ab1e9ea06a181ed7c397cea36c4f6bbd0849f55f45f03fbe1506de24c06ea9a1ad3aebd8959189bd3c3ed9547434eeb56d44a0552e907fcbb1dca124
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'apiql'
7
- spec.version = '0.4.3'
7
+ spec.version = '0.4.4'
8
8
  spec.authors = ['Dmitry Silchenko']
9
9
  spec.email = ['dmitry@desofto.com']
10
10
 
@@ -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[name] = @context.render_value(data, sub_schema)
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[name] = data
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[reg[:name]] = render_attribute(reg[:name], reg[:params].presence, sub_schema)
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[reg[:name]] = render_attribute(reg[:name], reg[:params].presence)
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.3
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-22 00:00:00.000000000 Z
11
+ date: 2018-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler