Class: ModelContextProtocol::Server::Resource
- Inherits:
-
Object
- Object
- ModelContextProtocol::Server::Resource
- Includes:
- Cancellable, Progressable
- Defined in:
- lib/model_context_protocol/server/resource.rb
Defined Under Namespace
Classes: AnnotationsDSL, DefinitionDSL
Class Attribute Summary collapse
-
.annotations ⇒ Object
readonly
Returns the value of attribute annotations.
-
.description ⇒ Object
readonly
Returns the value of attribute description.
-
.mime_type ⇒ Object
readonly
Returns the value of attribute mime_type.
-
.name ⇒ Object
readonly
Returns the value of attribute name.
-
.title ⇒ Object
readonly
Returns the value of attribute title.
-
.uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Attribute Summary collapse
-
#mime_type ⇒ Object
readonly
Returns the value of attribute mime_type.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize ⇒ Resource
constructor
A new instance of Resource.
Methods included from Progressable
Methods included from Cancellable
Constructor Details
#initialize ⇒ Resource
Returns a new instance of Resource.
8 9 10 11 |
# File 'lib/model_context_protocol/server/resource.rb', line 8 def initialize @mime_type = self.class.mime_type @uri = self.class.uri end |
Class Attribute Details
.annotations ⇒ Object (readonly)
Returns the value of attribute annotations.
51 52 53 |
# File 'lib/model_context_protocol/server/resource.rb', line 51 def annotations @annotations end |
.description ⇒ Object (readonly)
Returns the value of attribute description.
51 52 53 |
# File 'lib/model_context_protocol/server/resource.rb', line 51 def description @description end |
.mime_type ⇒ Object (readonly)
Returns the value of attribute mime_type.
51 52 53 |
# File 'lib/model_context_protocol/server/resource.rb', line 51 def mime_type @mime_type end |
.name ⇒ Object (readonly)
Returns the value of attribute name.
51 52 53 |
# File 'lib/model_context_protocol/server/resource.rb', line 51 def name @name end |
.title ⇒ Object (readonly)
Returns the value of attribute title.
51 52 53 |
# File 'lib/model_context_protocol/server/resource.rb', line 51 def title @title end |
.uri ⇒ Object (readonly)
Returns the value of attribute uri.
51 52 53 |
# File 'lib/model_context_protocol/server/resource.rb', line 51 def uri @uri end |
Instance Attribute Details
#mime_type ⇒ Object (readonly)
Returns the value of attribute mime_type.
6 7 8 |
# File 'lib/model_context_protocol/server/resource.rb', line 6 def mime_type @mime_type end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
6 7 8 |
# File 'lib/model_context_protocol/server/resource.rb', line 6 def uri @uri end |
Class Method Details
.call ⇒ Object
74 75 76 |
# File 'lib/model_context_protocol/server/resource.rb', line 74 def call new.call end |
.define(&block) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/model_context_protocol/server/resource.rb', line 53 def define(&block) definition_dsl = DefinitionDSL.new definition_dsl.instance_eval(&block) @name = definition_dsl.name @description = definition_dsl.description @title = definition_dsl.title @mime_type = definition_dsl.mime_type @uri = definition_dsl.uri @annotations = definition_dsl.defined_annotations end |
.definition ⇒ Object
78 79 80 81 82 83 |
# File 'lib/model_context_protocol/server/resource.rb', line 78 def definition result = {name: @name, description: @description, mimeType: @mime_type, uri: @uri} result[:title] = @title if @title result[:annotations] = @annotations.serialized if @annotations result end |
.inherited(subclass) ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'lib/model_context_protocol/server/resource.rb', line 65 def inherited(subclass) subclass.instance_variable_set(:@name, @name) subclass.instance_variable_set(:@description, @description) subclass.instance_variable_set(:@title, @title) subclass.instance_variable_set(:@mime_type, @mime_type) subclass.instance_variable_set(:@uri, @uri) subclass.instance_variable_set(:@annotations, @annotations&.dup) end |
Instance Method Details
#call ⇒ Object
13 14 15 |
# File 'lib/model_context_protocol/server/resource.rb', line 13 def call raise NotImplementedError, "Subclasses must implement the call method" end |