Class: Hoptoadr

Inherits:
Object
  • Object
show all
Defined in:
lib/hoptoadr.rb,
lib/hoptoadr/error.rb,
lib/hoptoadr/party.rb

Defined Under Namespace

Classes: Error, Party

Instance Method Summary collapse

Constructor Details

#initialize(account, auth_token) ⇒ Hoptoadr

Returns a new instance of Hoptoadr.



7
8
9
10
# File 'lib/hoptoadr.rb', line 7

def initialize(, auth_token)
  Party.base_uri "#{}.hoptoadapp.com"
  Party.default_params :auth_token => auth_token
end

Instance Method Details

#errorsObject



17
18
19
20
21
22
23
24
# File 'lib/hoptoadr.rb', line 17

def errors
  errors, page = [], 0
  begin
    errors_on_page = paginate(page += 1)
    errors += errors_on_page
  end while errors_on_page.size == 30 # "Errors are paginated. You get 30 at a time." -- http://bit.ly/88rupg
  errors
end

#paginate(page = 1) ⇒ Object



12
13
14
15
# File 'lib/hoptoadr.rb', line 12

def paginate(page = 1)
  resp = Party.paginate page
  resp['nil_classes'] ? [] : resp['groups'].map {|e| Error.new(e) }
end

#resolve_all_errorsObject



26
27
28
29
30
# File 'lib/hoptoadr.rb', line 26

def resolve_all_errors
  errors.each do |e|
    e.resolve
  end
end