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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -0
- data/lib/field_mask_parser/node.rb +5 -2
- data/lib/field_mask_parser/parser.rb +3 -3
- data/lib/field_mask_parser/version.rb +1 -1
- 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: abd7b203f702edddda3105a0b8e06434730064a7f82e891456f21843a8003c35
|
4
|
+
data.tar.gz: e5751642d4b68f54553d8fc622d355e8828ab6efcc3a43fb78a9d1ac2e41e9a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15cd94d6fefe9d29e38907eea218e0f285093f5c3b5433c3096e9b54eb25882c96f7a254c7555b5741662a65afa7e326f685e25d9c09425950678696feecde9e
|
7
|
+
data.tar.gz: 54044910777d3168571bf8b801e690fd947c704683b68c3818b0888d71ee2a7b376e4884aef393ef813df6da72d7ec6524b5907b9c784f50e74cdbc730f5efa5
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
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.
|
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-
|
11
|
+
date: 2018-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|