Skip to content

Commit

Permalink
Routing methods dsl refactored to get rid of explicit paths parameter
Browse files Browse the repository at this point in the history
Fixes #791
  • Loading branch information
AMar4enko committed Nov 14, 2014
1 parent 2302e26 commit 764c10f
Showing 1 changed file with 8 additions and 26 deletions.
34 changes: 8 additions & 26 deletions lib/grape/dsl/routing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,32 +115,14 @@ def route(methods, paths = ['/'], route_options = {}, &block)
reset_validations!
end

def get(paths = ['/'], options = {}, &block)
route('GET', paths, options, &block)
end

def post(paths = ['/'], options = {}, &block)
route('POST', paths, options, &block)
end

def put(paths = ['/'], options = {}, &block)
route('PUT', paths, options, &block)
end

def head(paths = ['/'], options = {}, &block)
route('HEAD', paths, options, &block)
end

def delete(paths = ['/'], options = {}, &block)
route('DELETE', paths, options, &block)
end

def options(paths = ['/'], options = {}, &block)
route('OPTIONS', paths, options, &block)
end

def patch(paths = ['/'], options = {}, &block)
route('PATCH', paths, options, &block)
%w"get pust put head delete options patch".each do |meth|
eval <<DEF_METHOD
def #{meth}(*args, &block)
options = args.extract_options!
paths = args.first || ['/']
route('#{meth.upcase}', paths, options, &block)
end
DEF_METHOD
end

def namespace(space = nil, options = {}, &block)
Expand Down

0 comments on commit 764c10f

Please sign in to comment.