Skip to content

Commit

Permalink
It's best to define respond_to_missing instead of respond_to?
Browse files Browse the repository at this point in the history
  • Loading branch information
marcandre committed May 5, 2012
1 parent 39eea48 commit 06fdafc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -1389,7 +1389,7 @@ patch them.)
```

* avoid using `method_missing` for metaprogramming. Backtraces become messy; the behavior is not listed in `#methods`; misspelled method calls might silently work (`nukes.launch_state = false`). Consider using delegation, proxy, or `define_method` instead. If you must, use `method_missing`,
- be sure to [also define `respond_to?`](http://devblog.avdi.org/2011/12/07/defining-method_missing-and-respond_to-at-the-same-time/)
- be sure to [also define `respond_to_missing?`](http://blog.marc-andre.ca/2010/11/methodmissing-politely.html)
- only catch methods with a well-defined prefix, such as `find_by_*` -- make your code as assertive as possible.
- call `super` at the end of your statement
- delegate to assertive, non-magical methods:
Expand Down

0 comments on commit 06fdafc

Please sign in to comment.