protobuf-mongoid 0.0.4 → 0.0.5
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 +4 -4
- data/lib/protobuf/mongoid/serialization.rb +36 -0
- data/lib/protobuf/mongoid/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: 1445d28771288f026291c7f40cfe34a21a0c6972762c3e983687cc05fc428a78
|
4
|
+
data.tar.gz: 8fc17a73e63b12a1727d96f9f26af93c007bb998c6a417ed217af8665cdddf48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85a60b044827db1f6988d8f3d03d882b19d80a4f1cd6416e7b2645418abc7d68019027e8fd150e63b95425e6ad6f385c07e2fc5b0fdaf4e97553aff79e10c30b
|
7
|
+
data.tar.gz: e37d6896ec0e6f973a03b1a5dc3d54bfb6e12d656738ad3529bc4cd987589b0cc9cd97f77dca66bdda99af3f66edc3b1205287ae1c2e9bbdb97a3aea7269133a
|
@@ -6,6 +6,9 @@ module Protobuf
|
|
6
6
|
module Serialization
|
7
7
|
extend ActiveSupport::Concern
|
8
8
|
|
9
|
+
OK = 200
|
10
|
+
BAD_REQUEST = 400
|
11
|
+
|
9
12
|
included do
|
10
13
|
class << self
|
11
14
|
attr_writer :_protobuf_field_symbol_transformers,
|
@@ -241,9 +244,42 @@ module Protobuf
|
|
241
244
|
hash[field] = field_object.call(self)
|
242
245
|
end
|
243
246
|
|
247
|
+
if hash.include?(:changed_attribute_names)
|
248
|
+
hash[:changed_attribute_names] = changed_fields_from_document
|
249
|
+
end
|
250
|
+
|
251
|
+
if hash.include?(:errors)
|
252
|
+
hash[:errors] = errors_for_protobuf
|
253
|
+
end
|
254
|
+
|
255
|
+
if hash.include?(:status_code)
|
256
|
+
hash[:status_code] = status_code_for_protobuf
|
257
|
+
end
|
258
|
+
|
244
259
|
hash
|
245
260
|
end
|
246
261
|
|
262
|
+
def changed_fields_from_document
|
263
|
+
changed_attribute_names = previous_changes.keys
|
264
|
+
|
265
|
+
changed_attribute_names
|
266
|
+
end
|
267
|
+
|
268
|
+
def status_code_for_protobuf
|
269
|
+
errors.empty? ? OK : BAD_REQUEST
|
270
|
+
end
|
271
|
+
|
272
|
+
def errors_for_protobuf
|
273
|
+
return [] if errors.empty?
|
274
|
+
|
275
|
+
errors.messages.map do |field, error_messages|
|
276
|
+
{
|
277
|
+
:field => field.to_s,
|
278
|
+
:messages => error_messages.map(&:to_s) # cast the messages to a string, because in Rails 6.1+ this is a ActiveModel::DeprecationHandlingMessageArray
|
279
|
+
}
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
247
283
|
# TODO: Assignment Branch Condition size for _protobuf_field_objects is too high. [<1, 19, 7> 20.27/17]
|
248
284
|
def _protobuf_field_objects(field)
|
249
285
|
self.class._protobuf_field_objects[field] ||=
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: protobuf-mongoid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luilver Garces
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-04-
|
11
|
+
date: 2025-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-protobuf
|