Class: Dcc::Plugin::Registry
- Inherits:
-
Object
- Object
- Dcc::Plugin::Registry
- Defined in:
- lib/dcc/plugin/registry.rb
Overview
Category-based registry. Each category (validators, converters, cli_commands) gets its own array. Thread-safe via a Mutex.
Class Method Summary collapse
- .all(category) ⇒ Array<Object>
- .any?(category) ⇒ Boolean
-
.categories ⇒ Array<Symbol>
The registered category names.
- .register(category, entry) ⇒ Class, Object
- .reset! ⇒ Object
Class Method Details
.all(category) ⇒ Array<Object>
24 25 26 |
# File 'lib/dcc/plugin/registry.rb', line 24 def all(category) @mutex.synchronize { @categories[category.to_sym].dup } end |
.any?(category) ⇒ Boolean
30 31 32 |
# File 'lib/dcc/plugin/registry.rb', line 30 def any?(category) @mutex.synchronize { !@categories[category.to_sym].empty? } end |
.categories ⇒ Array<Symbol>
Returns the registered category names.
39 40 41 |
# File 'lib/dcc/plugin/registry.rb', line 39 def categories @mutex.synchronize { @categories.keys.dup } end |
.register(category, entry) ⇒ Class, Object
15 16 17 18 19 20 |
# File 'lib/dcc/plugin/registry.rb', line 15 def register(category, entry) @mutex.synchronize do @categories[category.to_sym] << entry entry end end |
.reset! ⇒ Object
34 35 36 |
# File 'lib/dcc/plugin/registry.rb', line 34 def reset! @mutex.synchronize { @categories.clear } end |