Class: ActionMCP::RegistryBase::RegistryScope
- Inherits:
-
Object
- Object
- ActionMCP::RegistryBase::RegistryScope
- Includes:
- Enumerable
- Defined in:
- lib/action_mcp/registry_base.rb
Overview
Query object for chainable registry scopes.
Defined Under Namespace
Classes: Item
Instance Method Summary collapse
-
#each {|Item| ... } ⇒ void
Iterates over the items in the scope.
-
#find_available_tool(name) ⇒ Class?
Chainable finder for available tools by name.
-
#initialize(items) ⇒ void
constructor
Initializes a new RegistryScope instance.
-
#keys ⇒ Array<String>
Returns the names (keys) of all non-abstract items.
Constructor Details
#initialize(items) ⇒ void
Initializes a new RegistryScope instance.
118 119 120 121 122 |
# File 'lib/action_mcp/registry_base.rb', line 118 def initialize(items) @items = items.reject do |_name, klass| RegistryBase.send(:abstract_item?, klass) end.map { |name, klass| Item.new(name, klass) } end |
Instance Method Details
#each {|Item| ... } ⇒ void
This method returns an undefined value.
Iterates over the items in the scope.
128 129 130 |
# File 'lib/action_mcp/registry_base.rb', line 128 def each(&) @items.each(&) end |
#find_available_tool(name) ⇒ Class?
Chainable finder for available tools by name.
143 144 145 146 |
# File 'lib/action_mcp/registry_base.rb', line 143 def find_available_tool(name) item = @items.find { |i| i.name == name } item&.klass end |
#keys ⇒ Array<String>
Returns the names (keys) of all non-abstract items.
135 136 137 |
# File 'lib/action_mcp/registry_base.rb', line 135 def keys @items.map(&:name) end |