Class: Neovim::RemoteModule::DSL
- Inherits:
- BasicObject
- Defined in:
- lib/neovim/remote_module/dsl.rb
Overview
The DSL exposed in Neovim.start_remote
blocks.
Instance Attribute Summary collapse
- #handlers ⇒ Object readonly
Instance Method Summary collapse
-
#initialize(&block) ⇒ DSL
constructor
A new instance of DSL.
-
#register_handler(name, &block) ⇒ Object
Define an RPC handler for use in remote modules.
Constructor Details
#initialize(&block) ⇒ DSL
Returns a new instance of DSL.
9 10 11 12 13 14 15 16 17 |
# File 'lib/neovim/remote_module/dsl.rb', line 9 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 |
Instance Attribute Details
#handlers ⇒ Object (readonly)
7 8 9 |
# File 'lib/neovim/remote_module/dsl.rb', line 7 def handlers @handlers end |
Instance Method Details
#register_handler(name, &block) ⇒ Object
Define an RPC handler for use in remote modules.
23 24 25 26 27 |
# File 'lib/neovim/remote_module/dsl.rb', line 23 def register_handler(name, &block) @handlers[name.to_s] = ::Proc.new do |client, *args| block.call(client, *args) end end |