Class: Ask::MCP::Native::Messages::Notification

Inherits:
Object
  • Object
show all
Defined in:
lib/ask/mcp/native/messages.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method:, params: nil) ⇒ Notification

Returns a new instance of Notification.



37
38
39
40
# File 'lib/ask/mcp/native/messages.rb', line 37

def initialize(method:, params: nil)
  @method = method
  @params = params
end

Instance Attribute Details

#methodObject (readonly)

Returns the value of attribute method.



35
36
37
# File 'lib/ask/mcp/native/messages.rb', line 35

def method
  @method
end

#paramsObject (readonly)

Returns the value of attribute params.



35
36
37
# File 'lib/ask/mcp/native/messages.rb', line 35

def params
  @params
end

Instance Method Details

#to_hObject



42
43
44
45
46
47
48
49
# File 'lib/ask/mcp/native/messages.rb', line 42

def to_h
  h = {
    jsonrpc: JSON_RPC_VERSION,
    method: @method
  }
  h[:params] = @params if @params
  h
end

#to_json(*args) ⇒ Object



51
52
53
# File 'lib/ask/mcp/native/messages.rb', line 51

def to_json(*args)
  to_h.to_json(*args)
end