Class: GrpcKit::Codec

Inherits:
Object
  • Object
show all
Defined in:
lib/grpc_kit/codec.rb

Instance Method Summary collapse

Constructor Details

#initialize(marshal:, unmarshal:, marshal_method:, unmarshal_method:) ⇒ Codec

Returns a new instance of Codec.

Parameters:



9
10
11
12
13
14
# File 'lib/grpc_kit/codec.rb', line 9

def initialize(marshal:, unmarshal:, marshal_method:, unmarshal_method:)
  @marshal = marshal
  @unmarshal = unmarshal
  @marshal_method = marshal_method
  @unmarshal_method = unmarshal_method
end

Instance Method Details

#decode(data) ⇒ String

Parameters:

  • data (String)

Returns:

  • (String)


24
25
26
# File 'lib/grpc_kit/codec.rb', line 24

def decode(data)
  @unmarshal.send(@unmarshal_method, data)
end

#encode(data) ⇒ String

Parameters:

  • data (String)

Returns:

  • (String)


18
19
20
# File 'lib/grpc_kit/codec.rb', line 18

def encode(data)
  @marshal.send(@marshal_method, data)
end