protobuf-mongoid 0.0.4 → 0.0.6

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: 0ac335725540f15e340f3401ec521b254858643bb7f0196828ff8db573653b3b
4
- data.tar.gz: fa5549223e0ac4bdaee235c01bc968c865ee028b978e47c55bba4e5f02226849
3
+ metadata.gz: b8bae55625d55ac6aea5a5594e3002ac6dc0eb4e4e4a6d60fc4fa9f56f4988c8
4
+ data.tar.gz: 881b0c6c81c35e1f0687da5e1fa5b2ee6ea96eb34437649f6e0a4662b64395b3
5
5
  SHA512:
6
- metadata.gz: 0b4e8d54b6d2d863f330e876aa05aa4de21ff60071d8d07967db0f7d44380f2ddcc3206282e4552df42c5871f1d3dddff357e7e0960d8f6f8ddee360af66b084
7
- data.tar.gz: fd7bb771b4bdc0e723475a964636aa4d4f7476854cfb47523be05d83097caba2df99a94bb80a5e42dda254564c51b977b290ce1f4cc5e9dd8652d59fe06b2106
6
+ metadata.gz: e0bb9abf17c8f5bb0e628f32fe825d98ac8eabe89d723cee73f36680250d741827dc9dc6c1742d18aeafab2fb8f0b56144d122a601eaa5d1ec8ba9977bd3bc77
7
+ data.tar.gz: 80041fd1cfb09b8f1c42e57bd9de37bc96098fb92c779d593ef7e415edde5d76262ad17d018c74859ddc34cd216518400bee45ac6c54241b18e3364bb7a5ed7a
@@ -102,7 +102,8 @@ module Protobuf
102
102
  next unless proto.respond_to_and_has_and_present?(field)
103
103
 
104
104
  search_values = parse_search_values(proto, field)
105
- search_relation = search_relation.__send__(scope_name, *search_values)
105
+ search_relation = search_relation.__send__(scope_name, *search_values)
106
+ search_relation.selector[field] = { "$in" => search_values } if search_values.class == Array
106
107
  end
107
108
 
108
109
  search_relation
@@ -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] ||=
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Protobuf
4
4
  module Mongoid
5
- VERSION = '0.0.4'
5
+ VERSION = '0.0.6'
6
6
  end
7
7
  end
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
4
+ version: 0.0.6
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-29 00:00:00.000000000 Z
11
+ date: 2025-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-protobuf
@@ -164,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
164
  - !ruby/object:Gem::Version
165
165
  version: '0'
166
166
  requirements: []
167
- rubygems_version: 3.5.11
167
+ rubygems_version: 3.4.10
168
168
  signing_key:
169
169
  specification_version: 4
170
170
  summary: A gem to integrate Protocol Buffers with Mongoid.