Class: Escobar::Heroku::ConfigVars

Inherits:
Object
  • Object
show all
Defined in:
lib/escobar/heroku/config_vars.rb

Overview

Class representing a heroku application’s environment variables

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, app_id) ⇒ ConfigVars

Returns a new instance of ConfigVars.



6
7
8
9
# File 'lib/escobar/heroku/config_vars.rb', line 6

def initialize(client, app_id)
  @app_id = app_id
  @client = client
end

Instance Attribute Details

#app_idObject (readonly)

Returns the value of attribute app_id.



5
6
7
# File 'lib/escobar/heroku/config_vars.rb', line 5

def app_id
  @app_id
end

#clientObject (readonly)

Returns the value of attribute client.



5
6
7
# File 'lib/escobar/heroku/config_vars.rb', line 5

def client
  @client
end

Instance Method Details

#[](key) ⇒ Object

Retrieve an environmental variable by name



12
13
14
# File 'lib/escobar/heroku/config_vars.rb', line 12

def [](key)
  values[key]
end

#infoObject



20
21
22
23
24
25
26
27
# File 'lib/escobar/heroku/config_vars.rb', line 20

def info
  if info_json["id"] == "two_factor" &&
     info_json["message"].match(/second authentication factor/)
    {}
  else
    info_json
  end
end

#info_jsonObject



29
30
31
# File 'lib/escobar/heroku/config_vars.rb', line 29

def info_json
  @info_json ||= client.heroku.get("/apps/#{app_id}/config-vars")
end

#valuesObject



16
17
18
# File 'lib/escobar/heroku/config_vars.rb', line 16

def values
  @info ||= info
end