Class: Protobuf::Field::BaseFieldObjectDefinitions::MapSetMethod

Inherits:
Object
  • Object
show all
Defined in:
lib/protobuf/field/base_field_object_definitions.rb

Instance Method Summary collapse

Constructor Details

#initialize(selph) ⇒ MapSetMethod

Returns a new instance of MapSetMethod.



127
128
129
130
# File 'lib/protobuf/field/base_field_object_definitions.rb', line 127

def initialize(selph)
  @selph = selph
  @name = selph.name
end

Instance Method Details

#call(message_instance, bytes) ⇒ Object



132
133
134
135
136
137
138
139
# File 'lib/protobuf/field/base_field_object_definitions.rb', line 132

def call(message_instance, bytes)
  hash = message_instance[@name]
  entry = @selph.decode(bytes)
  # decoded value could be nil for an
  # enum value that is not recognized
  hash[entry.key] = entry.value unless entry.value.nil?
  hash[entry.key]
end