1.5.0 (latest) 1.4.1 1.3.0 1.2.0 1.1.0 1.0.1 0.26.0 0.25.0 0.24.0 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.
**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.
**Raises**

- (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.
**Parameter**

- **time** (Time) --- The Time to be converted.
**Returns**

- (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.
**Parameter**

- **timestamp** (Google::Protobuf::Timestamp) --- The timestamp to be converted.
**Returns**

- (Time) --- The converted Time.