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.
Constant Summary collapse
- Item =
Using a Data type for items.
Data.define(:name, :klass) do delegate :description, to: :klass end
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.
96 97 98 99 100 |
# File 'lib/action_mcp/registry_base.rb', line 96 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.
106 107 108 |
# File 'lib/action_mcp/registry_base.rb', line 106 def each(&) @items.each(&) end |
#find_available_tool(name) ⇒ Class?
Chainable finder for available tools by name.
121 122 123 124 |
# File 'lib/action_mcp/registry_base.rb', line 121 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.
113 114 115 |
# File 'lib/action_mcp/registry_base.rb', line 113 def keys @items.map(&:name) end |