Module: APIConfig

Defined in:
lib/api-config.rb

Defined Under Namespace

Classes: DeepStruct, Error

Constant Summary collapse

VERSION =
'0.4.8'

Class Method Summary collapse

Class Method Details

.add_file(which, file) ⇒ Object Also known as: set_file



38
39
40
41
42
# File 'lib/api-config.rb', line 38

def add_file(which, file)
  files[which] = file

  reload!(which)
end

.envObject



10
11
12
# File 'lib/api-config.rb', line 10

def env
  environment || ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
end

.env=(e) ⇒ Object



14
15
16
# File 'lib/api-config.rb', line 14

def env=(e)
  @@env = e
end

.get_file(which) ⇒ Object



45
46
47
# File 'lib/api-config.rb', line 45

def get_file(which)
  files[which]
end

.method_missing(m) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/api-config.rb', line 18

def method_missing(m)
  if configuration.key?(m)
    # Get named configuration
    configuration.fetch(m)
  else
    # Get item from default configuration
    configuration_for(:default).public_send(m)
  end
end

.reload!(which = :default) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/api-config.rb', line 28

def reload!(which = :default)
  if which == :all
    configuration.clear
    true
  else
    configuration.delete(which)
    configuration_for(which)
  end
end