mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Fixup macros
This commit is contained in:
parent
ac007f8565
commit
d16c55984c
1 changed files with 6 additions and 6 deletions
|
@ -68,10 +68,10 @@ module Spectator
|
||||||
|
|
||||||
if response
|
if response
|
||||||
# Return configured response.
|
# Return configured response.
|
||||||
response.as(Response(\{{NT[{{meth.name.symbolize}}]}})).value
|
response.as(Response(\{{type}})).value
|
||||||
else
|
else
|
||||||
# Response not configured for this method/message.
|
# Response not configured for this method/message.
|
||||||
raise UnexpectedMessage.new("#{_spectator_double_name} received unexpected message :{{meth.name}} with (<TODO: ARGS>).")
|
raise UnexpectedMessage.new("#{_spectator_double_name} received unexpected message :{{meth.name}} (masking ancestor) with (<TODO: ARGS>).")
|
||||||
end
|
end
|
||||||
\{% else %}
|
\{% else %}
|
||||||
# Return type doesn't match configured type.
|
# Return type doesn't match configured type.
|
||||||
|
@ -88,10 +88,10 @@ module Spectator
|
||||||
|
|
||||||
if response
|
if response
|
||||||
# Return configured response.
|
# Return configured response.
|
||||||
response.as(Response(\{{NT[{{meth.name.symbolize}}]}})).value
|
response.as(Response(\{{type}})).value
|
||||||
else
|
else
|
||||||
# Response not configured for this method/message.
|
# Response not configured for this method/message.
|
||||||
raise UnexpectedMessage.new("#{_spectator_double_name} received unexpected message :{{meth.name}} with (<TODO: ARGS>).")
|
raise UnexpectedMessage.new("#{_spectator_double_name} received unexpected message :{{meth.name}} (masking ancestor) with (<TODO: ARGS>).")
|
||||||
end
|
end
|
||||||
{% end %}
|
{% end %}
|
||||||
\{% else %}
|
\{% else %}
|
||||||
|
@ -111,14 +111,14 @@ module Spectator
|
||||||
# Handle all methods but only respond to configured messages.
|
# Handle all methods but only respond to configured messages.
|
||||||
# Raises an `UnexpectedMessage` error for non-configures messages.
|
# Raises an `UnexpectedMessage` error for non-configures messages.
|
||||||
macro method_missing(call)
|
macro method_missing(call)
|
||||||
\{% if NT.keys.includes?({{call.name.symbolize}}.id) %}
|
\{% if type = NT[{{call.name.symbolize}}] %}
|
||||||
# Find a suitable response.
|
# Find a suitable response.
|
||||||
call = MethodCall.capture({{call.name.symbolize}}, {{call.args.splat}})
|
call = MethodCall.capture({{call.name.symbolize}}, {{call.args.splat}})
|
||||||
response = @responses.find &.===(call)
|
response = @responses.find &.===(call)
|
||||||
|
|
||||||
if response
|
if response
|
||||||
# Return configured response.
|
# Return configured response.
|
||||||
response.as(Response(\{{NT[{{call.name.symbolize}}]}})).value
|
response.as(Response(\{{type}})).value
|
||||||
else
|
else
|
||||||
# Response not configured for this method/message.
|
# Response not configured for this method/message.
|
||||||
raise UnexpectedMessage.new("#{_spectator_double_name} received unexpected message :{{call.name}} with (<TODO: ARGS>).")
|
raise UnexpectedMessage.new("#{_spectator_double_name} received unexpected message :{{call.name}} with (<TODO: ARGS>).")
|
||||||
|
|
Loading…
Reference in a new issue