Module: TicketingHub::Configuration

Included in:
TicketingHub
Defined in:
lib/ticketing_hub/configuration.rb

Constant Summary collapse

VALID_OPTIONS_KEYS =
[
:adapter,
:faraday_config_block,
:api_version,
:api_endpoint,
:oauth_endpoint,
:client_id,
:client_secret,
:oauth_token,
:proxy,
:user_agent,
:request_host,
:auto_traversal].freeze
DEFAULT_ADAPTER =
Faraday.default_adapter
DEFAULT_API_VERSION =
1
DEFAULT_API_ENDPOINT =
ENV['TH_API_ENDPOINT'] || 'https://api.ticketinghub.com/'
DEFAULT_OAUTH_ENDPOINT =
ENV['TH_OAUTH_ENDPOINT'] || 'https://www.ticketinghub.com/oauth/'
DEFAULT_USER_AGENT =
"TicketingHub Ruby Gem #{TicketingHub::VERSION}".freeze
DEFAULT_AUTO_TRAVERSAL =
false

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



30
31
32
# File 'lib/ticketing_hub/configuration.rb', line 30

def self.extended base
  base.reset
end

Instance Method Details

#api_endpoint=(value) ⇒ Object



44
45
46
# File 'lib/ticketing_hub/configuration.rb', line 44

def api_endpoint= value
  @api_endpoint = File.join value, ''
end

#configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



34
35
36
# File 'lib/ticketing_hub/configuration.rb', line 34

def configure
  yield self
end

#faraday_config(&block) ⇒ Object



48
49
50
# File 'lib/ticketing_hub/configuration.rb', line 48

def faraday_config &block
  @faraday_config_block = block
end

#optionsObject



38
39
40
41
42
# File 'lib/ticketing_hub/configuration.rb', line 38

def options
  VALID_OPTIONS_KEYS.each_with_object Hash.new do |key, memo|
    memo[key] = send key
  end
end

#resetObject



52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/ticketing_hub/configuration.rb', line 52

def reset
  self.adapter        = DEFAULT_ADAPTER
  self.api_version    = DEFAULT_API_VERSION
  self.api_endpoint   = DEFAULT_API_ENDPOINT
  self.oauth_endpoint = DEFAULT_OAUTH_ENDPOINT
  self.client_id      = nil
  self.client_secret  = nil
  self.oauth_token    = nil
  self.proxy          = nil
  self.request_host   = nil
  self.user_agent     = DEFAULT_USER_AGENT
  self.auto_traversal = DEFAULT_AUTO_TRAVERSAL
end