Sha256: d82bff78c6ebe14388971fd6a5ae2aa3cdb55f1571a78565cf742bce549f8a76

Contents?: true

Size: 767 Bytes

Versions: 1

Compression:

Stored size: 767 Bytes

Contents

module Neovim
  class RemoteModule
    # The DSL exposed in +Neovim.start_remote+ blocks.
    #
    # @api public
    class DSL < BasicObject
      attr_reader :handlers

      def initialize(&block)
        @handlers = ::Hash.new do |h, name|
          h[name] = ::Proc.new do |_, *|
            raise NotImplementedError, "undefined handler #{name.inspect}"
          end
        end

        block&.call(self)
      end

      # Define an RPC handler for use in remote modules.
      #
      # @param name [String] The handler name.
      # @param block [Proc] The body of the handler.
      def register_handler(name, &block)
        @handlers[name.to_s] = ::Proc.new do |client, *args|
          block.call(client, *args)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
neovim-0.10.0 lib/neovim/remote_module/dsl.rb