apiql 0.3.3 → 0.3.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 +18 -15
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bdbc7a6ae370719e2cf99317eecb62b1d55cb102f5e6c139efbaf3f834af3fe9
4
- data.tar.gz: fe6cd1969365185700487d36ea7f4daaad0c3adbb344207ea14237a7299af709
3
+ metadata.gz: da237b810c30af8f312652d463e5a4ba2ee980653052a74e0533ee46cba32ebd
4
+ data.tar.gz: 110df82b41b3cd9a670ce414c40fa61d8e872fc9067d25e2949f030fa746ded2
5
5
  SHA512:
6
- metadata.gz: 4e88a8c04a5f968a4a3ef2ce409ed68df1791103ff04732550b88cec6e6936145ae79054d99ad8102dbc8b448f015ddda9d399d28aa48e47e9762f78d2cc7fb1
7
- data.tar.gz: 8adb7c155531070ea9a33292d0243fe0c4007f3f3c90da09103199ba25f0a4d323316cd7d215984559fe65087022e78a98f73fdb8d0e228f698698b7f9b61bf8
6
+ metadata.gz: 01a25bbf772de28b18c1bc8d16e4e4bcddcb2feadbbe8a2218a8a6d526745a47ea71f12de7f383da317de68e880d01e25258aaf899a7b4c34b31a147ede70a85
7
+ data.tar.gz: 2b5a81697b13a95e2030d101d4c126af165c5422f4dffee8bc867098f37e0521f934d26adffc8bac8f20068c3a345b8584accacedd01847a38fcda8a86a537eb
data/apiql.gemspec CHANGED
@@ -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.3.3'
7
+ spec.version = '0.3.4'
8
8
  spec.authors = ['Dmitry Silchenko']
9
9
  spec.email = ['dmitry@desofto.com']
10
10
 
data/lib/apiql.rb CHANGED
@@ -246,7 +246,6 @@ class APIQL
246
246
  names = field.split('.')
247
247
  if names.count > 1
248
248
  o = nil
249
-
250
249
  names.each do |field|
251
250
  if o.present?
252
251
  if o.respond_to? field
@@ -301,19 +300,7 @@ class APIQL
301
300
  end
302
301
 
303
302
  if data.is_a?(Hash) && schema.present?
304
- respond = {}
305
-
306
- schema.each do |field|
307
- if field.is_a? Hash
308
- field.each do |field, sub_schema|
309
- respond[field] = render_value(data[field.to_sym], sub_schema)
310
- end
311
- else
312
- respond[field] = render_value(data[field.to_sym])
313
- end
314
- end
315
-
316
- respond
303
+ HashEntity.new(data, @context).render(schema)
317
304
  else
318
305
  render_value(data, schema)
319
306
  end
@@ -330,7 +317,23 @@ class APIQL
330
317
 
331
318
  class HashEntity < Entity
332
319
  def get_field(field, params = nil)
333
- object[field.to_sym]
320
+ o = nil
321
+
322
+ field.split('.').each do |name|
323
+ if o.present?
324
+ if o.respond_to? name
325
+ o = o.public_send(name)
326
+ else
327
+ o = nil
328
+ break
329
+ end
330
+ else
331
+ o = object[name.to_sym]
332
+ break unless o.present?
333
+ end
334
+ end
335
+
336
+ o
334
337
  end
335
338
  end
336
339
 
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.3.3
4
+ version: 0.3.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-07-20 00:00:00.000000000 Z
11
+ date: 2018-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler