fmcache 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b8c9d9c7ac9e3393596cfd826f53939f20d603cd2d2ce8b2368ea19672845bc
4
- data.tar.gz: 4c71c46a1f950ac0c6980b85529e883e655025e6eed472b56e84d2d5bf499987
3
+ metadata.gz: b79c05d630df6693c5e414e4c715beed1ec241e3731d71fa9e4bf93a4406e6e6
4
+ data.tar.gz: 074a40df96e911ac2a5150325075336daec5600e64ba53cd8956e0aa92a7d3c1
5
5
  SHA512:
6
- metadata.gz: 54735e1b19f1699a959a4867be5e66992811d73b8eef96c666ebb99d3d41c469c601c821c88209ae090b292b2c021404fab6176cbe5f302164fc052d1a1e8598
7
- data.tar.gz: c041b070719a1f808ae9e56cc50dc89a7917bea628e24f3927b8d7e6c7f28475b23665dd3e202346b1737af5a6408d2b0e8a263d3e5a5788556d5310812819fa
6
+ metadata.gz: 2319028a0e9cb0813e2a3e4bda3c28afb06a8e5305938ff3abb74fdd6885a2080b6025b90452525cbd34c641c191520ccea4f5b7cea9419cc83c2c5954f5054c
7
+ data.tar.gz: bac1356af719d330b90258d12429b4c32b3133d7e06176a5e7219532d4ff1cf8b5c463d9ccf318db5b24b301c29c80cf20a80be67af54ea9546964aa800650ff
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fmcache (0.3.0)
4
+ fmcache (0.4.0)
5
5
  field_mask_parser (~> 0.4.3)
6
6
 
7
7
  GEM
@@ -53,7 +53,11 @@ module FMCache
53
53
  r[name] = item.value
54
54
  end
55
55
  @has_ones.each do |name, data|
56
- r[name] = data.to_h
56
+ if data
57
+ r[name] = data.to_h
58
+ else
59
+ r[name] = nil
60
+ end
57
61
  end
58
62
  @has_manies.each do |name, data_list|
59
63
  r[name] = data_list.map(&:to_h)
@@ -29,10 +29,11 @@ module FMCache
29
29
  end
30
30
 
31
31
  field_mask.has_ones.each do |assoc|
32
- v = value[assoc.name] || {}
33
- p = prefix + [assoc.name]
34
-
35
- traverse!(value: v, field_mask: assoc, prefix: p, p_id: id)
32
+ v = value[assoc.name]
33
+ if v # NOTE: Proceed only when value exists
34
+ p = prefix + [assoc.name]
35
+ traverse!(value: v, field_mask: assoc, prefix: p, p_id: id)
36
+ end
36
37
  end
37
38
 
38
39
  field_mask.has_manies.each do |assoc|
@@ -10,10 +10,9 @@ module FMCache
10
10
 
11
11
  r = {}
12
12
  values.each do |value|
13
- h = {}
14
- fields.each do |f|
15
- h[f] = []
16
- end
13
+ # NOTE: `[]` is the default value of each field.
14
+ h = fields.map { |f| [f, []] }.to_h
15
+
17
16
  h.merge! encode_one(value, field_mask)
18
17
 
19
18
  id = value.fetch(:id)
@@ -1,3 +1,3 @@
1
1
  module FMCache
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fmcache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nao Minami
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-24 00:00:00.000000000 Z
11
+ date: 2018-12-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler