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.



1333
1334
1335
1336
# File 'lib/mockserver/models.rb', line 1333

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.



1331
1332
1333
# File 'lib/mockserver/models.rb', line 1331

def match_json
  @match_json
end

#responsesObject

Returns the value of attribute responses.



1331
1332
1333
# File 'lib/mockserver/models.rb', line 1331

def responses
  @responses
end

Class Method Details

.from_hash(data) ⇒ Object



1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
# File 'lib/mockserver/models.rb', line 1345

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



1338
1339
1340
1341
1342
1343
# File 'lib/mockserver/models.rb', line 1338

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