Class: HerokuSan::API

Inherits:
Object
  • Object
show all
Defined in:
lib/heroku_san/api.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ API

Returns a new instance of API.



5
6
7
# File 'lib/heroku_san/api.rb', line 5

def initialize(options = {})
  @heroku_api = Heroku::API.new(options)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/heroku_san/api.rb', line 9

def method_missing(name, *args)
  @heroku_api.send(name, *args)
rescue Heroku::API::Errors::ErrorWithResponse => error
  status = error.response.headers["Status"]
  msg = JSON.parse(error.response.body)['error'] rescue '???'
  error.set_backtrace([])
  $stderr.puts "\nHeroku API ERROR: #{status} (#{msg})\n\n"
  raise error
end