Skip to content

Commit

Permalink
A better way to handle no args: check for function type
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Fitzgerald committed Mar 31, 2012
1 parent 3a76cf8 commit b440630
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 5 additions & 1 deletion lib/swagger.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions src/swagger.coffee
Expand Up @@ -118,9 +118,13 @@ class SwaggerOperation

do: (args={}, callback, error) =>

# if no callback, must be being called without parameters
callback = args if (args? and !callback?)

# if the args is a function, then it must be a resource without
# parameters
if (typeof args) == "function"
error = callback
callback = args
args = {}

# Define a default error handler
unless error?
error = (xhr, textStatus, error) -> console.log xhr, textStatus, error
Expand Down

0 comments on commit b440630

Please sign in to comment.