Class: Dry::Schema::Macros::Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/mcp/tool.rb

Overview

Add description method to Hash macro

Instance Method Summary collapse

Instance Method Details

#call(&block) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/mcp/tool.rb', line 85

def call(&block)
  if block
    # Use current context to track nested context if available
    context = MetadataContext.current
    if context
      context.with_nested(name) do
        original_call(&block)
      end
    else
      original_call(&block)
    end
  else
    original_call(&block)
  end
end

#description(text) ⇒ Object



64
65
66
67
68
69
70
71
# File 'lib/mcp/tool.rb', line 64

def description(text)
  key_name = name.to_sym
  schema_dsl.meta(key_name, :description, text)

  # Mark this hash as having metadata so we know to track nested context
  @has_metadata = true
  self
end

#hidden(hidden = true) ⇒ Object

rubocop:disable Style/OptionalBooleanParameter



73
74
75
76
77
78
79
80
# File 'lib/mcp/tool.rb', line 73

def hidden(hidden = true) # rubocop:disable Style/OptionalBooleanParameter
  key_name = name.to_sym
  schema_dsl.meta(key_name, :hidden, hidden)

  # Mark this hash as having metadata so we know to track nested context
  @has_metadata = true
  self
end

#original_callObject

Override call method to manage nested context



83
# File 'lib/mcp/tool.rb', line 83

alias original_call call