Module: Hungrytable::Config

Defined in:
lib/hungrytable/config.rb

Overview

Configuration module for Hungrytable

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.base_urlObject



27
28
29
# File 'lib/hungrytable/config.rb', line 27

def base_url
  @base_url ||= 'https://secure.opentable.com/api/otapi_v3.ashx'
end

.oauth_keyObject



15
16
17
18
19
# File 'lib/hungrytable/config.rb', line 15

def oauth_key
  @oauth_key ||= ENV.fetch('OT_OAUTH_KEY') do
    raise ConfigurationError, 'OT_OAUTH_KEY must be set via ENV or Config.oauth_key='
  end
end

.oauth_secretObject



21
22
23
24
25
# File 'lib/hungrytable/config.rb', line 21

def oauth_secret
  @oauth_secret ||= ENV.fetch('OT_OAUTH_SECRET') do
    raise ConfigurationError, 'OT_OAUTH_SECRET must be set via ENV or Config.oauth_secret='
  end
end

.partner_idObject



9
10
11
12
13
# File 'lib/hungrytable/config.rb', line 9

def partner_id
  @partner_id ||= ENV.fetch('OT_PARTNER_ID') do
    raise ConfigurationError, 'OT_PARTNER_ID must be set via ENV or Config.partner_id='
  end
end

Class Method Details

.reset!Object

Reset configuration to defaults (useful for testing)



32
33
34
35
36
37
# File 'lib/hungrytable/config.rb', line 32

def reset!
  @partner_id = nil
  @oauth_key = nil
  @oauth_secret = nil
  @base_url = nil
end

.valid?Boolean

Check if all required configuration is present



40
41
42
43
44
45
# File 'lib/hungrytable/config.rb', line 40

def valid?
  partner_id && oauth_key && oauth_secret
  true
rescue ConfigurationError
  false
end