Class: Qs::Heroku::Client::App

Inherits:
Object
  • Object
show all
Defined in:
lib/qs/heroku/client/app.rb

Constant Summary collapse

SIZES =
{
  '1x' => 1,
  '2x' => 2
}

Instance Method Summary collapse

Constructor Details

#initialize(id, connection) ⇒ App

Returns a new instance of App.



13
14
15
16
# File 'lib/qs/heroku/client/app.rb', line 13

def initialize(id, connection)
  @id = id
  @connection = connection
end

Instance Method Details

#formationObject



18
19
20
21
# File 'lib/qs/heroku/client/app.rb', line 18

def formation
  response = @connection.request(:get, "/apps/#{CGI.escape(@id)}/formation")
  parse_formation(response)
end

#scale(type, quantity, size = nil) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/qs/heroku/client/app.rb', line 23

def scale(type, quantity, size = nil)
  options = {'quantity' => quantity}
  if size
    raise Error.new("Unknown size: #{size}!") unless SIZES[size]
    options['size'] = SIZES[size]
  end
  response = @connection.request(:patch, "/apps/#{CGI.escape(@id)}/formation/#{CGI.escape(type)}", options)
  parse_formation(response)
end