field_mask_parser 0.2.0 → 0.3.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: 268dcafa5e3c30786903d78669b94b076f518b114c0ebb62a50c6a78b0873cb5
4
- data.tar.gz: 58d51f75abcd111c40a349fbbff7955b02eb01f211453a9d4845dae2aac4e537
3
+ metadata.gz: abd7b203f702edddda3105a0b8e06434730064a7f82e891456f21843a8003c35
4
+ data.tar.gz: e5751642d4b68f54553d8fc622d355e8828ab6efcc3a43fb78a9d1ac2e41e9a3
5
5
  SHA512:
6
- metadata.gz: 376e5ce91f5cd5fd92d1b87d4226e3220c004fed05960a289286aad6bd5c657fcae691e7dd965c86779ff5fbccc80e0e59b0994a8d850926c0b34c10fac1e71b
7
- data.tar.gz: 9b2a71040e43de2ce5e8d95b4ea39e3b1c5450b82928e2bea1346c7443e37612dbf00288c4478998f95b70d6170952ae49447ffd722c95f4e62f4d5757c1de32
6
+ metadata.gz: 15cd94d6fefe9d29e38907eea218e0f285093f5c3b5433c3096e9b54eb25882c96f7a254c7555b5741662a65afa7e326f685e25d9c09425950678696feecde9e
7
+ data.tar.gz: 54044910777d3168571bf8b801e690fd947c704683b68c3818b0888d71ee2a7b376e4884aef393ef813df6da72d7ec6524b5907b9c784f50e74cdbc730f5efa5
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- field_mask_parser (0.2.0)
4
+ field_mask_parser (0.3.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -59,10 +59,12 @@ end
59
59
  =>
60
60
  {
61
61
  :name=>nil,
62
+ :is_leaf=>false,
62
63
  :attrs=>[:id],
63
64
  :assocs=>[
64
65
  {
65
66
  :name=>:profile,
67
+ :is_leaf=>false,
66
68
  :attrs=>[:name],
67
69
  :assocs=>[]
68
70
  }
@@ -1,14 +1,16 @@
1
1
  module FieldMaskParser
2
2
  class Node
3
- attr_reader :name, :is_leaf, :attrs, :assocs
3
+ attr_reader :name, :is_leaf, :klass, :attrs, :assocs
4
4
 
5
5
  # @param [Symbol | NilClass] name nil when being top-level node
6
6
  # @param [bool] is_leaf
7
7
  # @param [<Symbol>] attrs
8
8
  # @param [Set<Node>] assocs
9
- def initialize(name:, is_leaf:)
9
+ # @param [ActiveRecord::Base] klass
10
+ def initialize(name:, is_leaf:, klass:)
10
11
  @name = name
11
12
  @is_leaf = is_leaf
13
+ @klass = klass
12
14
  @attrs = []
13
15
  @assocs = []
14
16
  end
@@ -27,6 +29,7 @@ module FieldMaskParser
27
29
  {
28
30
  name: @name,
29
31
  is_leaf: @is_leaf,
32
+ klass: @klass,
30
33
  attrs: @attrs,
31
34
  assocs: @assocs.map(&:to_h)
32
35
  }
@@ -12,7 +12,7 @@ module FieldMaskParser
12
12
 
13
13
  # @reutrn [Node]
14
14
  def parse
15
- r = Node.new(name: nil, is_leaf: false)
15
+ r = Node.new(name: nil, is_leaf: false, klass: @root)
16
16
  set_attrs_and_assocs!(r, @attrs_or_assocs, @root)
17
17
  r
18
18
  end
@@ -29,10 +29,10 @@ module FieldMaskParser
29
29
  # NOTE: If dhn.is_leaf is false, it is invalid. But ignore it now.
30
30
  node.push_attr(name)
31
31
  when Dispatcher::Type::ASSOCIATION
32
- n = Node.new(name: name, is_leaf: dhn.is_leaf)
32
+ _klass = get_assoc_klass(klass, name)
33
+ n = Node.new(name: name, is_leaf: dhn.is_leaf, klass: _klass)
33
34
  node.push_assoc(n)
34
35
  if dhn.children.size > 0
35
- _klass = get_assoc_klass(klass, name)
36
36
  set_attrs_and_assocs!(n, dhn.children, _klass)
37
37
  end
38
38
  when Dispatcher::Type::UNKNOWN
@@ -1,3 +1,3 @@
1
1
  module FieldMaskParser
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: field_mask_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.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-08-30 00:00:00.000000000 Z
11
+ date: 2018-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler