Skip to content

Instantly share code, notes, and snippets.

@kingsleyh
Created January 2, 2018 16:53
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 kingsleyh/ee6fbb3edc0f8bb3b611d5e8521254ea to your computer and use it in GitHub Desktop.
Save kingsleyh/ee6fbb3edc0f8bb3b611d5e8521254ea to your computer and use it in GitHub Desktop.
generics
def onParams(context, klass : T, &block) forall T
result = klass.parse(contextToJson(context))
p typeof(result)
if result.is_a?(T)
yield result
else
HTTPCodes.notFound(context, {message: result})
end
end
onParams(context, AddGroup) do |addGroup|
# do stuff
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment