Class: MockServer::GrpcBidiRule

Inherits:
Object
  • Object
show all
Defined in:
lib/mockserver/models.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(match_json: nil, responses: nil) ⇒ GrpcBidiRule

Returns a new instance of GrpcBidiRule.



1269
1270
1271
1272
# File 'lib/mockserver/models.rb', line 1269

def initialize(match_json: nil, responses: nil)
  @match_json = match_json
  @responses = responses
end

Instance Attribute Details

#match_jsonObject

Returns the value of attribute match_json.



1267
1268
1269
# File 'lib/mockserver/models.rb', line 1267

def match_json
  @match_json
end

#responsesObject

Returns the value of attribute responses.



1267
1268
1269
# File 'lib/mockserver/models.rb', line 1267

def responses
  @responses
end

Class Method Details

.from_hash(data) ⇒ Object



1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
# File 'lib/mockserver/models.rb', line 1281

def self.from_hash(data)
  return nil if data.nil?

  responses_data = data['responses']
  responses = responses_data&.map { |r| GrpcStreamMessage.from_hash(r) }
  new(
    match_json: data['matchJson'],
    responses:  responses
  )
end

Instance Method Details

#to_hObject



1274
1275
1276
1277
1278
1279
# File 'lib/mockserver/models.rb', line 1274

def to_h
  result = {}
  result['matchJson'] = @match_json unless @match_json.nil?
  result['responses'] = @responses&.map(&:to_h) if @responses
  result
end