Reference documentation and code samples for the gapic-common module Gapic::Protobuf.
A set of internal utilities for coercing data to protobuf messages.
Methods
.coerce
defself.coerce(hash,to:)->Object
Creates an instance of a protobuf message from a hash that may include nested hashes. google/protobuf allows
for the instantiation of protobuf messages using hashes but does not allow for nested hashes to instantiate
nested submessages.
Parameters
hash (Hash, Object) — The hash to be converted into a proto message. If an instance of the proto message
class is given, it is returned unchanged.
to (Class) — The corresponding protobuf message class of the given hash.
Returns
(Object) — An instance of the given message class.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["# gapic-common - Module Gapic::Protobuf (v1.1.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.1.0 (latest)](/ruby/docs/reference/gapic-common/latest/Gapic-Protobuf)\n- [1.0.1](/ruby/docs/reference/gapic-common/1.0.1/Gapic-Protobuf)\n- [0.26.0](/ruby/docs/reference/gapic-common/0.26.0/Gapic-Protobuf)\n- [0.25.0](/ruby/docs/reference/gapic-common/0.25.0/Gapic-Protobuf)\n- [0.24.0](/ruby/docs/reference/gapic-common/0.24.0/Gapic-Protobuf) \nReference documentation and code samples for the gapic-common module Gapic::Protobuf.\n\nA set of internal utilities for coercing data to protobuf messages.\n\nMethods\n-------\n\n### .coerce\n\n def self.coerce(hash, to:) -\u003e Object\n\nCreates an instance of a protobuf message from a hash that may include nested hashes. `google/protobuf` allows\nfor the instantiation of protobuf messages using hashes but does not allow for nested hashes to instantiate\nnested submessages. \n**Parameters**\n\n- **hash** (Hash, Object) --- The hash to be converted into a proto message. If an instance of the proto message class is given, it is returned unchanged.\n- **to** (Class) --- The corresponding protobuf message class of the given hash. \n**Returns**\n\n- (Object) --- An instance of the given message class. \n**Raises**\n\n- (ArgumentError)\n\n### .time_to_timestamp\n\n def self.time_to_timestamp(time) -\u003e Google::Protobuf::Timestamp\n\nUtility for converting a Ruby Time instance to a Google::Protobuf::Timestamp. \n**Parameter**\n\n- **time** (Time) --- The Time to be converted. \n**Returns**\n\n- (Google::Protobuf::Timestamp) --- The converted Google::Protobuf::Timestamp.\n\n### .timestamp_to_time\n\n def self.timestamp_to_time(timestamp) -\u003e Time\n\nUtility for converting a Google::Protobuf::Timestamp instance to a Ruby time. \n**Parameter**\n\n- **timestamp** (Google::Protobuf::Timestamp) --- The timestamp to be converted. \n**Returns**\n\n- (Time) --- The converted Time."]]