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
def self.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.
- 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.
- (Object) — An instance of the given message class.
- (ArgumentError)
.time_to_timestamp
def self.time_to_timestamp(time) -> Google::Protobuf::Timestamp
Utility for converting a Ruby Time instance to a Google::Protobuf::Timestamp.
- time (Time) — The Time to be converted.
- (Google::Protobuf::Timestamp) — The converted Google::Protobuf::Timestamp.
.timestamp_to_time
def self.timestamp_to_time(timestamp) -> Time
Utility for converting a Google::Protobuf::Timestamp instance to a Ruby time.
- timestamp (Google::Protobuf::Timestamp) — The timestamp to be converted.
- (Time) — The converted Time.