grape
grape copied to clipboard
endpoint method_missing vs override inspect
#2236 has added a method_missing to override the NoMethodError message since it was huge inside any endpoints. I found that it's been fixed in ruby 3.3 and the solution was to not use inspect on undefined method. I think that instead of using a method_missing strategy we could simply override endpoint's inspect method like this:
def inspect
"#{self.class} in `#{route.origin}' endpoint"
end
and we would achieve the same thing. Any thoughts ?
Happy New Year :)
This is some advanced ruby-fu, so ... I don't know? :)
This is some advanced ruby-fu, so ... I don't know? :)
IMO, I would just override the inspect. It's faster than passing by method_missing which is notoriously known to be slow.