Skip to content

Instantly share code, notes, and snippets.

@codesword
Created June 5, 2016 12:24
Show Gist options
  • Select an option

  • Save codesword/b31cc743f7054d02770622e8044540e8 to your computer and use it in GitHub Desktop.

Select an option

Save codesword/b31cc743f7054d02770622e8044540e8 to your computer and use it in GitHub Desktop.
class Router
[:get, :post, :put, :patch, :delete].each do |method_name|
define_method(method_name) do
"This is a #{method_name} method"
end
end
end
router = Router.new
router.get #=> "This is a get method"
router.post #=> "This is a post method"
router.delete #=> "This is a delete method"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment