Class: Panda::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/panda/config.rb

Instance Method Summary collapse

Instance Method Details

#adapter(adapter_name) ⇒ Object



26
27
28
# File 'lib/panda/config.rb', line 26

def adapter(adapter_name)
  Panda.adapter = adapter_name
end

#adapter=(adapter_name) ⇒ Object



30
31
32
# File 'lib/panda/config.rb', line 30

def adapter=(adapter_name)
  Panda.adapter = adapter_name
end

#configObject



6
7
8
# File 'lib/panda/config.rb', line 6

def config
  @config ||= {}
end

#parse_panda_url(panda_url) ⇒ Object

Setup connection for Heroku



35
36
37
38
39
40
41
42
43
44
# File 'lib/panda/config.rb', line 35

def parse_panda_url(panda_url)
  panda_uri = URI.parse(panda_url)

  config['access_key'] = panda_uri.user
  config['secret_key'] = panda_uri.password
  config['cloud_id']   = panda_uri.path[1..-1]
  config['api_host']   = panda_uri.host
  config['api_port']   = API_PORT
  config
end

#region(region) ⇒ Object

Set the correct api_host for US/EU



47
48
49
50
51
52
53
54
55
# File 'lib/panda/config.rb', line 47

def region(region)
  if(region.to_s == 'us')
    config['api_host'] = US_API_HOST
  elsif(region.to_s == 'eu')
    config['api_host'] = EU_API_HOST
  else
    raise "Region Unknown"
  end
end

#to_hashObject



22
23
24
# File 'lib/panda/config.rb', line 22

def to_hash
  config
end