Sha256: f6bf73596707121457193f5e467d11348907f40bb8200f770047f16f20adb01d

Contents?: true

Size: 1000 Bytes

Versions: 7

Compression:

Stored size: 1000 Bytes

Contents

module LanguageServer
  module Protocol
    module Interfaces
      class ResponseMessage
        def initialize(id:, result: nil, error: nil)
          @attributes = {}

          @attributes[:id] = id
          @attributes[:result] = result if result
          @attributes[:error] = error if error

          @attributes.freeze
        end

        #
        # The request id.
        #
        # @return [string | number]
        def id
          attributes.fetch(:id)
        end

        #
        # The result of a request. This can be omitted in
        # the case of an error.
        #
        # @return [any]
        def result
          attributes.fetch(:result)
        end

        #
        # The error object in case a request fails.
        #
        # @return [ResponseError<any>]
        def error
          attributes.fetch(:error)
        end

        attr_reader :attributes

        def to_json(*args)
          attributes.to_json(*args)
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
language_server-protocol-0.2.0 lib/language_server/protocol/interfaces/response_message.rb
language_server-protocol-0.1.0 lib/language_server/protocol/interfaces/response_message.rb
language_server-0.4.0 lib/language_server/protocol/interfaces/response_message.rb
language_server-0.3.1 lib/language_server/protocol/interfaces/response_message.rb
language_server-0.3.0 lib/language_server/protocol/interfaces/response_message.rb
language_server-0.2.0 lib/language_server/protocol/interfaces/response_message.rb
language_server-0.1.0 lib/language_server/protocol/interfaces/response_message.rb