Class: ModelContextProtocol::Server::Content::EmbeddedResource

Inherits:
Data
  • Object
show all
Defined in:
lib/model_context_protocol/server/content.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#metaObject (readonly)

Returns the value of attribute meta

Returns:

  • (Object)

    the current value of meta



155
156
157
# File 'lib/model_context_protocol/server/content.rb', line 155

def meta
  @meta
end

#resourceObject (readonly)

Returns the value of attribute resource

Returns:

  • (Object)

    the current value of resource



155
156
157
# File 'lib/model_context_protocol/server/content.rb', line 155

def resource
  @resource
end

Instance Method Details

#serializedObject



156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/model_context_protocol/server/content.rb', line 156

def serialized
  serialized_data = {
    _meta: meta,
    resource:,
    type: "resource"
  }.compact

  validation_errors = JSON::Validator.fully_validate(schema, serialized_data)
  if validation_errors.empty?
    serialized_data
  else
    raise ContentValidationError, validation_errors.join(", ")
  end
end