Class: MockServer::GrpcStreamMessage

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(json: nil, template_type: nil, delay: nil) ⇒ GrpcStreamMessage

Returns a new instance of GrpcStreamMessage.



1530
1531
1532
1533
1534
# File 'lib/mockserver/models.rb', line 1530

def initialize(json: nil, template_type: nil, delay: nil)
  @json = json
  @template_type = template_type
  @delay = delay
end

Instance Attribute Details

#delayObject

template_type marks the message json as a response template rendered by the named engine (VELOCITY / JAVASCRIPT / MUSTACHE), mirroring the server GrpcStreamResponseDTO / GrpcBidiResponseDTO message templateType.



1528
1529
1530
# File 'lib/mockserver/models.rb', line 1528

def delay
  @delay
end

#jsonObject

template_type marks the message json as a response template rendered by the named engine (VELOCITY / JAVASCRIPT / MUSTACHE), mirroring the server GrpcStreamResponseDTO / GrpcBidiResponseDTO message templateType.



1528
1529
1530
# File 'lib/mockserver/models.rb', line 1528

def json
  @json
end

#template_typeObject

template_type marks the message json as a response template rendered by the named engine (VELOCITY / JAVASCRIPT / MUSTACHE), mirroring the server GrpcStreamResponseDTO / GrpcBidiResponseDTO message templateType.



1528
1529
1530
# File 'lib/mockserver/models.rb', line 1528

def template_type
  @template_type
end

Class Method Details

.from_hash(data) ⇒ Object



1544
1545
1546
1547
1548
1549
1550
1551
1552
# File 'lib/mockserver/models.rb', line 1544

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

  new(
    json:          data['json'],
    template_type: data['templateType'],
    delay:         Delay.from_hash(data['delay'])
  )
end

Instance Method Details

#to_hObject



1536
1537
1538
1539
1540
1541
1542
# File 'lib/mockserver/models.rb', line 1536

def to_h
  result = {}
  result['json'] = @json unless @json.nil?
  result['templateType'] = @template_type unless @template_type.nil?
  result['delay'] = @delay.to_h if @delay
  result
end