Class: Protobuf::Field::BaseFieldObjectDefinitions::RequiredMapSetField
- Inherits:
-
Object
- Object
- Protobuf::Field::BaseFieldObjectDefinitions::RequiredMapSetField
- Defined in:
- lib/protobuf/field/base_field_object_definitions.rb
Instance Method Summary collapse
- #call(values, value, _ignore_nil_for_repeated, message_instance) ⇒ Object
-
#initialize(selph) ⇒ RequiredMapSetField
constructor
A new instance of RequiredMapSetField.
Constructor Details
#initialize(selph) ⇒ RequiredMapSetField
Returns a new instance of RequiredMapSetField.
175 176 177 178 179 |
# File 'lib/protobuf/field/base_field_object_definitions.rb', line 175 def initialize(selph) @selph = selph @tag = selph.tag @fully_qualified_name = selph.fully_qualified_name end |
Instance Method Details
#call(values, value, _ignore_nil_for_repeated, message_instance) ⇒ Object
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/protobuf/field/base_field_object_definitions.rb', line 181 def call(values, value, _ignore_nil_for_repeated, ) unless value.is_a?(Hash) fail TypeError, <<-TYPE_ERROR Expected map value Got '#{value.class}' for map protobuf field #{@selph.name} TYPE_ERROR end if value.empty? values.delete(@fully_qualified_name) . << @tag else ..delete(@tag) values[@fully_qualified_name] ||= ::Protobuf::Field::FieldHash.new(@selph) values[@fully_qualified_name].replace(value) end end |