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.



1241
1242
1243
1244
# File 'lib/mockserver/models.rb', line 1241

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.



1239
1240
1241
# File 'lib/mockserver/models.rb', line 1239

def match_json
  @match_json
end

#responsesObject

Returns the value of attribute responses.



1239
1240
1241
# File 'lib/mockserver/models.rb', line 1239

def responses
  @responses
end

Class Method Details

.from_hash(data) ⇒ Object



1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
# File 'lib/mockserver/models.rb', line 1253

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



1246
1247
1248
1249
1250
1251
# File 'lib/mockserver/models.rb', line 1246

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