Class: Heroku::Helpers::HerokuPostgresql::Attachment

Inherits:
Object
  • Object
show all
Defined in:
lib/heroku/helpers/heroku_postgresql.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw) ⇒ Attachment


10
11
12
13
14
15
16
17
18
# File 'lib/heroku/helpers/heroku_postgresql.rb', line 10

def initialize(raw)
  @raw = raw
  @app           = raw['app']['name']
  @name          = raw['name'] || raw['config_var'].sub(/_URL\Z/, '')
  @config_var    = raw['config_var']
  @resource_name = raw['resource']['name']
  @url           = raw['resource']['value']
  @addon, @plan  = raw['resource']['type'].split(':')
end

Instance Attribute Details

#addonObject (readonly)

Returns the value of attribute addon


9
10
11
# File 'lib/heroku/helpers/heroku_postgresql.rb', line 9

def addon
  @addon
end

#appObject (readonly)

Returns the value of attribute app


9
10
11
# File 'lib/heroku/helpers/heroku_postgresql.rb', line 9

def app
  @app
end

#config_varObject (readonly)

Returns the value of attribute config_var


9
10
11
# File 'lib/heroku/helpers/heroku_postgresql.rb', line 9

def config_var
  @config_var
end

#nameObject (readonly)

Returns the value of attribute name


9
10
11
# File 'lib/heroku/helpers/heroku_postgresql.rb', line 9

def name
  @name
end

#planObject (readonly)

Returns the value of attribute plan


9
10
11
# File 'lib/heroku/helpers/heroku_postgresql.rb', line 9

def plan
  @plan
end

#resource_nameObject (readonly)

Returns the value of attribute resource_name


9
10
11
# File 'lib/heroku/helpers/heroku_postgresql.rb', line 9

def resource_name
  @resource_name
end

#urlObject (readonly)

Returns the value of attribute url


9
10
11
# File 'lib/heroku/helpers/heroku_postgresql.rb', line 9

def url
  @url
end

Instance Method Details

#display_nameObject


24
25
26
# File 'lib/heroku/helpers/heroku_postgresql.rb', line 24

def display_name
  config_var + (primary_attachment? ? " (DATABASE_URL)"  : '')
end

#primary_attachment!Object


28
29
30
# File 'lib/heroku/helpers/heroku_postgresql.rb', line 28

def primary_attachment!
  @primary_attachment = true
end

#primary_attachment?Boolean


32
33
34
# File 'lib/heroku/helpers/heroku_postgresql.rb', line 32

def primary_attachment?
  @primary_attachment
end

#starter_plan?Boolean


20
21
22
# File 'lib/heroku/helpers/heroku_postgresql.rb', line 20

def starter_plan?
  plan =~ /dev|basic/
end