Class: VerizonApi::Config

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

Class Method Summary collapse

Class Method Details

.[](key) ⇒ Object



23
24
25
26
# File 'lib/verizon_api/config.rb', line 23

def self.[](key)
  return nil unless @config
  @config[key]
end

.include?(key) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/verizon_api/config.rb', line 19

def self.include?(key)
  @config.include?(key)
end

.load(source) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/verizon_api/config.rb', line 2

def self.load(source)
  @config = {
    :api_host           => 'api.edgecast.com',
    :api_token          => nil,
  }

  if source.is_a?(String)
    raise "Config file #{source} not found" unless File.exist?(source)

    config = YAML.load_file(source)
    @config.merge! config if config

  elsif source.is_a?(Hash)
    @config.merge! source
  end
end

.to_yamlObject



28
29
30
31
# File 'lib/verizon_api/config.rb', line 28

def self.to_yaml
  return nil unless @config
  @config.to_yaml
end