Created
March 11, 2009 01:35
-
-
Save TheNicholasNick/77243 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BaseModel < CouchRest::ExtendedDocument | |
# I like nil instead of Exceptions when resources can not be found. | |
def self.get(id) | |
begin | |
super | |
rescue RestClient::ResourceNotFound | |
nil | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < BaseModel | |
# now User.get("bogus_id") returns nil - win! | |
... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment