Class: ConfigFor::Config Private

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/config_for/config.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Constant Summary collapse

CONFIG_CLASS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

ActiveSupport::HashWithIndifferentAccess

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, name) ⇒ Config

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Config.



18
19
20
21
22
23
# File 'lib/config_for/config.rb', line 18

def initialize(path, name)
  @path = path
  @name = name
  @monitor = Monitor.new
  @pathname = Pathname("#{name}.yml").expand_path(path)
end

Class Method Details

.emptyObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



25
26
27
# File 'lib/config_for/config.rb', line 25

def self.empty
  CONFIG_CLASS.new
end

Instance Method Details

#environmentsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



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

def environments
  config.keys
end

#fetch(key, &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



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

def fetch(key, &block)
  config.fetch(key, &block)
rescue KeyError
  raise ConfigFor::MissingEnvironmentError, "#{@pathname} contains just #{environments}, not #{key}"
end