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 7083d32
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 26 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
0.9.1 (Next)
============
* [#813](/~https://github.com/intridea/grape/pull/813): Routing methods dsl refactored to get rid of explicit `paths` parameter - [@AlexYankee](/~https://github.com/AlexYankee).
* [#803](/~https://github.com/intridea/grape/pull/803): Added `all_or_none_of` parameter validator - [@loveltyoic](/~https://github.com/loveltyoic).
* [#774](/~https://github.com/intridea/grape/pull/774): Extended `mutually_exclusive`, `exactly_one_of`, `at_least_one_of` to work inside any kind of group: `requires` or `optional`, `Hash` or `Array` - [@ShPakvel](/~https://github.com/ShPakvel).
* [#743](/~https://github.com/intridea/grape/pull/743): Added `allow_blank` parameter validator to validate non-empty strings - [@elado](/~https://github.com/elado).
Expand Down
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 7083d32

Please sign in to comment.