Class: ActionMCP::RegistryBase
- Inherits:
-
Object
- Object
- ActionMCP::RegistryBase
- Defined in:
- lib/action_mcp/registry_base.rb
Overview
Base class for registries.
Direct Known Subclasses
Defined Under Namespace
Classes: NotFound, RegistryScope
Class Method Summary collapse
-
.clear! ⇒ void
Clears the registry cache.
-
.find(name) ⇒ Class
Retrieve an item by name.
-
.items ⇒ Hash
Returns all registered items.
-
.non_abstract ⇒ RegistryScope
Chainable scope: returns only non-abstract items.
-
.register(klass) ⇒ void
Register an item explicitly.
-
.size ⇒ Integer
Return the number of registered items, ignoring abstract ones.
-
.unregister(klass) ⇒ void
Unregister an item.
Class Method Details
.clear! ⇒ void
This method returns an undefined value.
Clears the registry cache.
64 65 66 |
# File 'lib/action_mcp/registry_base.rb', line 64 def clear! @items = nil end |
.find(name) ⇒ Class
Retrieve an item by name.
40 41 42 43 44 45 |
# File 'lib/action_mcp/registry_base.rb', line 40 def find(name) item = items[name] raise NotFound, "Item '#{name}' not found." if item.nil? item end |
.items ⇒ Hash
Returns all registered items.
13 14 15 |
# File 'lib/action_mcp/registry_base.rb', line 13 def items @items ||= {} end |
.non_abstract ⇒ RegistryScope
Chainable scope: returns only non-abstract items.
57 58 59 |
# File 'lib/action_mcp/registry_base.rb', line 57 def non_abstract RegistryScope.new(items) end |
.register(klass) ⇒ void
This method returns an undefined value.
Register an item explicitly
21 22 23 24 25 |
# File 'lib/action_mcp/registry_base.rb', line 21 def register(klass) return if klass.abstract? items[klass.capability_name] = klass end |
.size ⇒ Integer
Return the number of registered items, ignoring abstract ones.
50 51 52 |
# File 'lib/action_mcp/registry_base.rb', line 50 def size items.size end |
.unregister(klass) ⇒ void
This method returns an undefined value.
Unregister an item
31 32 33 |
# File 'lib/action_mcp/registry_base.rb', line 31 def unregister(klass) items.delete(klass.capability_name) end |