Class: PuppetEditorServices::Protocol::JsonRPCMessages::Message
- Inherits:
-
Object
- Object
- PuppetEditorServices::Protocol::JsonRPCMessages::Message
- Defined in:
- lib/puppet_editor_services/protocol/json_rpc_messages.rb
Overview
Protocol message primitives
Direct Known Subclasses
Instance Attribute Summary collapse
-
#jsonrpc ⇒ Object
Returns the value of attribute jsonrpc.
Instance Method Summary collapse
- #from_h!(value) ⇒ Object
-
#initialize(initial_hash = nil) ⇒ Message
constructor
A new instance of Message.
- #to_h ⇒ Object
- #to_json(*options) ⇒ Object
Constructor Details
#initialize(initial_hash = nil) ⇒ Message
Returns a new instance of Message.
12 13 14 15 |
# File 'lib/puppet_editor_services/protocol/json_rpc_messages.rb', line 12 def initialize(initial_hash = nil) @jsonrpc = ::PuppetEditorServices::Protocol::JsonRPC::JSONRPC_VERSION from_h!(initial_hash) end |
Instance Attribute Details
#jsonrpc ⇒ Object
Returns the value of attribute jsonrpc.
10 11 12 |
# File 'lib/puppet_editor_services/protocol/json_rpc_messages.rb', line 10 def jsonrpc @jsonrpc end |
Instance Method Details
#from_h!(value) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/puppet_editor_services/protocol/json_rpc_messages.rb', line 17 def from_h!(value) return self if value.nil? || value.empty? # jsonrpc is a little special. Don't override it with nil. This # allows `.new.from_h!(..)` to use the default without knowing exactly # what version is used. self.jsonrpc = value['jsonrpc'] unless value['jsonrpc'].nil? self end |
#to_h ⇒ Object
31 32 33 34 35 |
# File 'lib/puppet_editor_services/protocol/json_rpc_messages.rb', line 31 def to_h { 'jsonrpc' => jsonrpc } end |
#to_json(*options) ⇒ Object
27 28 29 |
# File 'lib/puppet_editor_services/protocol/json_rpc_messages.rb', line 27 def to_json(*) to_h.to_json() end |