Class: RailsAiBridge::Registry::ContextProviderDefinition
- Inherits:
-
Data
- Object
- Data
- RailsAiBridge::Registry::ContextProviderDefinition
- Defined in:
- lib/rails_ai_bridge/registry/context_provider_definition.rb
Overview
Immutable value object describing a context provider service declared in the registry manifest.
Context providers are external services (currently MCP servers) that the bridge can query for project context. This definition is preparatory — the data structures mirror the Rust runtime's manifest format, but no integration consumes them yet.
Instance Attribute Summary collapse
-
#endpoint ⇒ String
readonly
Provider HTTP endpoint base URL.
-
#optional ⇒ Boolean
readonly
Whether the provider may be skipped when unavailable.
-
#tools ⇒ Array<ContextToolSpec>
readonly
Tools requested from the provider.
-
#type ⇒ String
readonly
Provider type, e.g.
Class Method Summary collapse
-
.from_json(hash) ⇒ ContextProviderDefinition
Builds a ContextProviderDefinition from a parsed JSON hash.
Instance Method Summary collapse
Instance Attribute Details
#endpoint ⇒ String (readonly)
Returns provider HTTP endpoint base URL.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rails_ai_bridge/registry/context_provider_definition.rb', line 21 ContextProviderDefinition = Data.define(:type, :endpoint, :optional, :tools) do # Builds a {ContextProviderDefinition} from a parsed JSON hash. # # @param hash [Hash] parsed JSON object # @return [ContextProviderDefinition] # @raise [ArgumentError] when a required field is missing def self.from_json(hash) new( type: hash.fetch('type'), endpoint: hash.fetch('endpoint'), optional: hash.fetch('optional', false), tools: (hash['tools'] || []).map { |tool| ContextToolSpec.from_json(tool) } ) rescue KeyError => error raise ArgumentError, "Context provider definition missing required field: #{error.key}" end # @return [Boolean] def optional? = optional end |
#optional ⇒ Boolean (readonly)
Returns whether the provider may be skipped when unavailable.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rails_ai_bridge/registry/context_provider_definition.rb', line 21 ContextProviderDefinition = Data.define(:type, :endpoint, :optional, :tools) do # Builds a {ContextProviderDefinition} from a parsed JSON hash. # # @param hash [Hash] parsed JSON object # @return [ContextProviderDefinition] # @raise [ArgumentError] when a required field is missing def self.from_json(hash) new( type: hash.fetch('type'), endpoint: hash.fetch('endpoint'), optional: hash.fetch('optional', false), tools: (hash['tools'] || []).map { |tool| ContextToolSpec.from_json(tool) } ) rescue KeyError => error raise ArgumentError, "Context provider definition missing required field: #{error.key}" end # @return [Boolean] def optional? = optional end |
#tools ⇒ Array<ContextToolSpec> (readonly)
Returns tools requested from the provider.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rails_ai_bridge/registry/context_provider_definition.rb', line 21 ContextProviderDefinition = Data.define(:type, :endpoint, :optional, :tools) do # Builds a {ContextProviderDefinition} from a parsed JSON hash. # # @param hash [Hash] parsed JSON object # @return [ContextProviderDefinition] # @raise [ArgumentError] when a required field is missing def self.from_json(hash) new( type: hash.fetch('type'), endpoint: hash.fetch('endpoint'), optional: hash.fetch('optional', false), tools: (hash['tools'] || []).map { |tool| ContextToolSpec.from_json(tool) } ) rescue KeyError => error raise ArgumentError, "Context provider definition missing required field: #{error.key}" end # @return [Boolean] def optional? = optional end |
#type ⇒ String (readonly)
Returns provider type, e.g. "mcp".
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rails_ai_bridge/registry/context_provider_definition.rb', line 21 ContextProviderDefinition = Data.define(:type, :endpoint, :optional, :tools) do # Builds a {ContextProviderDefinition} from a parsed JSON hash. # # @param hash [Hash] parsed JSON object # @return [ContextProviderDefinition] # @raise [ArgumentError] when a required field is missing def self.from_json(hash) new( type: hash.fetch('type'), endpoint: hash.fetch('endpoint'), optional: hash.fetch('optional', false), tools: (hash['tools'] || []).map { |tool| ContextToolSpec.from_json(tool) } ) rescue KeyError => error raise ArgumentError, "Context provider definition missing required field: #{error.key}" end # @return [Boolean] def optional? = optional end |
Class Method Details
.from_json(hash) ⇒ ContextProviderDefinition
Builds a RailsAiBridge::Registry::ContextProviderDefinition from a parsed JSON hash.
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rails_ai_bridge/registry/context_provider_definition.rb', line 27 def self.from_json(hash) new( type: hash.fetch('type'), endpoint: hash.fetch('endpoint'), optional: hash.fetch('optional', false), tools: (hash['tools'] || []).map { |tool| ContextToolSpec.from_json(tool) } ) rescue KeyError => error raise ArgumentError, "Context provider definition missing required field: #{error.key}" end |
Instance Method Details
#optional? ⇒ Boolean
39 |
# File 'lib/rails_ai_bridge/registry/context_provider_definition.rb', line 39 def optional? = optional |