Class: PuppetEditorServices::Protocol::JsonRPCMessages::RequestMessage

Inherits:
Message
  • Object
show all
Defined in:
lib/puppet_editor_services/protocol/json_rpc_messages.rb

Overview

interface RequestMessage extends Message

/**
 * The request id.
 */
id: number | string;
/**
 * The method to be invoked.
 */
method: string;
/**
 * The method's params.
 */
params?: Array<any> | object;

Instance Attribute Summary collapse

Attributes inherited from Message

#jsonrpc

Instance Method Summary collapse

Methods inherited from Message

#to_json

Constructor Details

#initialize(initial_hash = nil) ⇒ RequestMessage

Returns a new instance of RequestMessage.



55
56
57
# File 'lib/puppet_editor_services/protocol/json_rpc_messages.rb', line 55

def initialize(initial_hash = nil)
  super
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



53
54
55
# File 'lib/puppet_editor_services/protocol/json_rpc_messages.rb', line 53

def id
  @id
end

#paramsObject

Returns the value of attribute params.



53
54
55
# File 'lib/puppet_editor_services/protocol/json_rpc_messages.rb', line 53

def params
  @params
end

#rpc_methodObject

Returns the value of attribute rpc_method.



53
54
55
# File 'lib/puppet_editor_services/protocol/json_rpc_messages.rb', line 53

def rpc_method
  @rpc_method
end

Instance Method Details

#from_h!(value) ⇒ Object



59
60
61
62
63
64
65
66
# File 'lib/puppet_editor_services/protocol/json_rpc_messages.rb', line 59

def from_h!(value)
  value = {} if value.nil?
  super
  self.id = value['id']
  self.rpc_method = value['method']
  self.params = value['params']
  self
end

#to_hObject



68
69
70
71
72
73
74
# File 'lib/puppet_editor_services/protocol/json_rpc_messages.rb', line 68

def to_h
  super.merge(
    'id' => id,
    'method' => rpc_method,
    'params' => params
  )
end