The `initialize` method was missing the assignment of `@resource`, causing the resource method to always return `nil` and `to_h` to return an incorrect hash with an empty resource value. Added comprehensive tests to verify the fix and prevent regression.
18 lines
359 B
Ruby
18 lines
359 B
Ruby
# frozen_string_literal: true
|
|
|
|
module MCP
|
|
class Resource
|
|
class Embedded
|
|
attr_reader :resource, :annotations
|
|
|
|
def initialize(resource:, annotations: nil)
|
|
@resource = resource
|
|
@annotations = annotations
|
|
end
|
|
|
|
def to_h
|
|
{ resource: resource.to_h, annotations: annotations }.compact
|
|
end
|
|
end
|
|
end
|
|
end
|