Module: ConnectProto::Extensions::Valueable

Defined in:
lib/extensions/valueable.rb

Class Method Summary collapse

Class Method Details

.to_value(value) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/extensions/valueable.rb', line 6

def self.to_value(value)
  case value
  when TrueClass, FalseClass then Google::Protobuf::Value.new(bool_value: value)
  when String then Google::Protobuf::Value.new(string_value: value)
  when Numeric then Google::Protobuf::Value.new(number_value: value)
  when NilClass then Google::Protobuf::Value.new(null_value: :NULL_VALUE)
  else
    raise TypeError, "Invalid type #{value.class} for value #{value}"
  end
end