Skip to content

Instantly share code, notes, and snippets.

@croaky
Created July 30, 2008 22:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save croaky/3350 to your computer and use it in GitHub Desktop.
Save croaky/3350 to your computer and use it in GitHub Desktop.
Access the Hoptoad (http://hoptoadapp.com) API with Ruby's ActiveResource
# 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 }
@turadg
Copy link

turadg commented Sep 22, 2011

s/hoptoad/airbrake

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment