Skip to content

Instantly share code, notes, and snippets.

@luislavena
Created December 7, 2017 22:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luislavena/ac5255db75c0dd9343ecfc34b611f194 to your computer and use it in GitHub Desktop.
Save luislavena/ac5255db75c0dd9343ecfc34b611f194 to your computer and use it in GitHub Desktop.
abstract class Foo
VERBS = %w(GET POST PUT)
{% for method in ::Foo::VERBS %}
macro {{ method.downcase.id }}(*args, **params)
\{% params[:via] = {{ method.downcase }} %}
match(\{{*args}}, \{{**params}})
end
{% end %}
def self.match(*args, **params)
puts args, params
end
end
class Bar < Foo
get "/path", to: "X"
end
{"/path"}
{to: "X", via: "get"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment