bmx-event_hook_client_server 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bc7d2f796a48e21c05195ba59b512492a0072d682588d5f44e128b61bf9a8206
4
- data.tar.gz: 6676229df74ada7025cf459f045fc43108cebc54708631eba5abf55dd4962706
3
+ metadata.gz: 0e901049720a2543310a586ca7789a2e00ae0d18a03a9c7638d9a15a8c5e955c
4
+ data.tar.gz: 0bf216b9852132a370680a21633542aba5b8ef15eda7f78208852c2ff8a63b53
5
5
  SHA512:
6
- metadata.gz: f36d5257e1270870ec6db6160bf3c514b06c6c8195e7e409f1df75f8560064c557d34c417ac346c1bb15f1d71df833a1538b19fd2a48ee55617240134f7324a5
7
- data.tar.gz: 10f9572b55a7af8853ac25b1026cb86eb991b6a6644f294c7851872d5c4a6f4bc685b11cb24c7b7c871ac3d463481bcefda19517d4d7228c88f76a6051b8cc95
6
+ metadata.gz: eee9f04e4997a0293bb88b3d6358aab20b069a64a6268fd7b3c6b04029093940d32a2a4442dc3fd334b4623795ddea93b6b97b2376c34598b5218322f3096c69
7
+ data.tar.gz: b26407a27bd6eda16e4cdd95045b7d5f71f8a65cf4f45781d2a3da2895dc981660b470de22c3c040f7e91f490693fc1ae85dda80ab4481d0210715299fb43eb7
@@ -4,6 +4,60 @@ module EventHookClientServer
4
4
  module Refinements
5
5
  module Protobuf
6
6
  module HashableStructValues
7
+ message_klasses =
8
+ ObjectSpace
9
+ .each_object(Class)
10
+ .select { |klass| klass < Google::Protobuf::MessageExts }
11
+
12
+ message_klasses.each do |klass|
13
+ refine klass do
14
+ def to_h
15
+ return to_a if self.class == Google::Protobuf::RepeatedField
16
+
17
+ keys = self.class.descriptor.map(&:name)
18
+
19
+ keys.each_with_object({}) do |key, hash|
20
+ value = send(key)
21
+
22
+ hash[key.to_sym] =
23
+ if value.is_a?(Google::Protobuf::MessageExts)
24
+ value.to_h
25
+ elsif value.class == Google::Protobuf::RepeatedField
26
+ value.to_a
27
+ else
28
+ value
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+
35
+
36
+ refine Google::Protobuf::RepeatedField do
37
+ def to_a
38
+ puts 'ARRAY'
39
+ map do |value|
40
+ if value.is_a?(Google::Protobuf::MessageExts)
41
+ value.to_h
42
+ elsif value.class == Google::Protobuf::RepeatedField
43
+ value.to_a
44
+ else
45
+ value
46
+ end
47
+ end
48
+ end
49
+ end
50
+
51
+ refine Google::Protobuf::StringValue do
52
+ def to_h
53
+ hash = super
54
+
55
+ return unless hash
56
+
57
+ hash[:value]
58
+ end
59
+ end
60
+
7
61
  refine Google::Protobuf::Struct do
8
62
  def to_h
9
63
  fields.each_with_object({}) do |(key, value), hash|
@@ -3,6 +3,6 @@
3
3
  module EventHookClientServer
4
4
  MAJOR = 1
5
5
  MINOR = 0
6
- PATCH = 3
6
+ PATCH = 4
7
7
  VERSION = [MAJOR, MINOR, PATCH].join('.')
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bmx-event_hook_client_server
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stanko K.R.