Use accessor method in server_context_with_meta instead of ivar
## Motivation and Context `server_context_with_meta` reads `@server_context` (the instance variable) directly instead of calling the `server_context` accessor method. This prevents subclasses from overriding `server_context`. Ffor example, to provide thread-local context in multi-threaded servers like Puma. Fixes #271. ## How Has This Been Tested? Added a regression test and passed. ## Breaking Changes None. This restores the expected behavior of `attr_accessor :server_context`.
This commit is contained in:
parent
e189d7852a
commit
a2575b24e5
1 changed files with 30 additions and 4 deletions
|
|
@ -531,14 +531,14 @@ module MCP
|
|||
|
||||
def server_context_with_meta(request)
|
||||
meta = request[:_meta]
|
||||
if meta && @server_context.is_a?(Hash)
|
||||
context = @server_context.dup
|
||||
if meta && server_context.is_a?(Hash)
|
||||
context = server_context.dup
|
||||
context[:_meta] = meta
|
||||
context
|
||||
elsif meta && @server_context.nil?
|
||||
elsif meta && server_context.nil?
|
||||
{ _meta: meta }
|
||||
else
|
||||
@server_context
|
||||
server_context
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue