Class: RuVim::CommandRegistry
- Inherits:
-
Object
- Object
- RuVim::CommandRegistry
- Includes:
- Singleton
- Defined in:
- lib/ruvim/command_registry.rb
Defined Under Namespace
Classes: CommandSpec
Instance Method Summary collapse
- #all ⇒ Object
- #clear! ⇒ Object
- #fetch(id) ⇒ Object
-
#initialize ⇒ CommandRegistry
constructor
A new instance of CommandRegistry.
- #register(id, call:, desc: "", source: :builtin) ⇒ Object
- #registered?(id) ⇒ Boolean
Constructor Details
#initialize ⇒ CommandRegistry
Returns a new instance of CommandRegistry.
15 16 17 |
# File 'lib/ruvim/command_registry.rb', line 15 def initialize @specs = {} end |
Instance Method Details
#all ⇒ Object
32 33 34 |
# File 'lib/ruvim/command_registry.rb', line 32 def all @specs.values.sort_by(&:id) end |
#clear! ⇒ Object
36 37 38 |
# File 'lib/ruvim/command_registry.rb', line 36 def clear! @specs.clear end |
#fetch(id) ⇒ Object
24 25 26 |
# File 'lib/ruvim/command_registry.rb', line 24 def fetch(id) @specs.fetch(id.to_s) end |
#register(id, call:, desc: "", source: :builtin) ⇒ Object
19 20 21 22 |
# File 'lib/ruvim/command_registry.rb', line 19 def register(id, call:, desc: "", source: :builtin) key = id.to_s @specs[key] = CommandSpec.new(id: key, call:, desc:, source:) end |
#registered?(id) ⇒ Boolean
28 29 30 |
# File 'lib/ruvim/command_registry.rb', line 28 def registered?(id) @specs.key?(id.to_s) end |