Created
July 30, 2008 22:20
-
-
Save croaky/3350 to your computer and use it in GitHub Desktop.
Access the Hoptoad (http://hoptoadapp.com) API with Ruby's ActiveResource
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
# tests at http://gist.github.com/3354 | |
class Hoptoad < ActiveResource::Base | |
self.site = "http://your_account.hoptoadapp.com" | |
class << self | |
@@auth_token = 'your_auth_token' | |
def find(*arguments) | |
arguments = append_auth_token_to_params(*arguments) | |
super(*arguments) | |
end | |
def append_auth_token_to_params(*arguments) | |
opts = arguments.last.is_a?(Hash) ? arguments.pop : {} | |
opts = opts.has_key?(:params) ? opts : opts.merge(:params => {}) | |
opts[:params] = opts[:params].merge(:auth_token => @@auth_token) | |
arguments << opts | |
arguments | |
end | |
end | |
end | |
class Error < Hoptoad | |
end | |
# Errors are paginated. You get 30 at a time. | |
@errors = Error.find :all | |
@errors = Error.find :all, :params => { :page => 2 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
s/hoptoad/airbrake