diff --git a/lib/tapioca/dsl/compilers/protobuf.rb b/lib/tapioca/dsl/compilers/protobuf.rb index 21d57805b..a97dd5512 100644 --- a/lib/tapioca/dsl/compilers/protobuf.rb +++ b/lib/tapioca/dsl/compilers/protobuf.rb @@ -284,6 +284,11 @@ def create_descriptor_method(klass, desc) return_type: "void", ) + klass.create_method( + "clear_#{field.name}", + return_type: "void", + ) + field end diff --git a/spec/tapioca/dsl/compilers/protobuf_spec.rb b/spec/tapioca/dsl/compilers/protobuf_spec.rb index e1bef6865..91ca06bb2 100644 --- a/spec/tapioca/dsl/compilers/protobuf_spec.rb +++ b/spec/tapioca/dsl/compilers/protobuf_spec.rb @@ -60,6 +60,12 @@ class Cart sig { params(customer_id: T.nilable(Integer), shop_id: T.nilable(Integer)).void } def initialize(customer_id: nil, shop_id: nil); end + sig { void } + def clear_customer_id; end + + sig { void } + def clear_shop_id; end + sig { returns(Integer) } def customer_id; end @@ -97,6 +103,9 @@ class Cart sig { params(events: T.nilable(String)).void } def initialize(events: nil); end + sig { void } + def clear_events; end + sig { returns(String) } def events; end @@ -136,6 +145,9 @@ def cart_item_index; end sig { params(value: T.nilable(Google::Protobuf::UInt64Value)).void } def cart_item_index=(value); end + + sig { void } + def clear_cart_item_index; end end RBI @@ -171,6 +183,9 @@ class Cart sig { params(value_type: T.nilable(T.any(Symbol, Integer))).void } def initialize(value_type: nil); end + sig { void } + def clear_value_type; end + sig { returns(T.any(Symbol, Integer)) } def value_type; end @@ -233,6 +248,9 @@ class Cart sig { params(value_type: T.nilable(T.any(Symbol, Integer))).void } def initialize(value_type: nil); end + sig { void } + def clear_value_type; end + sig { returns(T.any(Symbol, Integer)) } def value_type; end @@ -267,6 +285,12 @@ class Cart sig { params(customer_ids: T.nilable(T.any(Google::Protobuf::RepeatedField[Integer], T::Array[Integer])), indices: T.nilable(T.any(Google::Protobuf::RepeatedField[Google::Protobuf::UInt64Value], T::Array[Google::Protobuf::UInt64Value]))).void } def initialize(customer_ids: Google::Protobuf::RepeatedField.new(:int32), indices: Google::Protobuf::RepeatedField.new(:message, Google::Protobuf::UInt64Value)); end + sig { void } + def clear_customer_ids; end + + sig { void } + def clear_indices; end + sig { returns(Google::Protobuf::RepeatedField[Integer]) } def customer_ids; end @@ -307,6 +331,12 @@ class Cart sig { params(customers: T.nilable(T.any(Google::Protobuf::Map[String, Integer], T::Hash[String, Integer])), stores: T.nilable(T.any(Google::Protobuf::Map[String, Google::Protobuf::UInt64Value], T::Hash[String, Google::Protobuf::UInt64Value]))).void } def initialize(customers: Google::Protobuf::Map.new(:string, :int32), stores: Google::Protobuf::Map.new(:string, :message, Google::Protobuf::UInt64Value)); end + sig { void } + def clear_customers; end + + sig { void } + def clear_stores; end + sig { returns(Google::Protobuf::Map[String, Integer]) } def customers; end @@ -428,6 +458,12 @@ def ShopName; end sig { params(value: String).void } def ShopName=(value); end + + sig { void } + def clear_ShopID; end + + sig { void } + def clear_ShopName; end end RBI @@ -453,6 +489,13 @@ def ShopName=(value); end rbi_output = rbi_for(:Cart) assert_includes(rbi_output, indented(<<~RBI, 2)) + + sig { void } + def clear_email; end + + sig { void } + def clear_phone_number; end + sig { returns(T.nilable(Symbol)) } def contact_info; end RBI