Module: Konfig

Defined in:
lib/konfig.rb,
lib/konfig/store.rb,
lib/konfig/adapter.rb,
lib/konfig/helpers.rb,
lib/konfig/evaluator.rb,
lib/konfig/rails/railtie.rb,
lib/konfig/child_class_manager.rb,
lib/konfig/rails/adapters/smtp_adapter.rb,
lib/konfig/rails/adapters/asset_expansion_adapter.rb

Overview

Provides a global accessor for configuration. ie. Konfig

Defined Under Namespace

Modules: ChildClassManager, Helpers Classes: Adapter, AssetExpansionAdapter, Evaluator, InitializeKonfig, SmtpAdapter, Store

Class Method Summary collapse

Class Method Details

.[](key) ⇒ Object

Hash-style access to data

Parameters:

  • key (String, Symbol)


23
24
25
26
27
28
# File 'lib/konfig.rb', line 23

def self.[](key)
  if !@default_store
    raise "Konfig default store not set. Call Konfig.load(path) to set one."
  end
  @default_store[key]
end

.default_storeObject



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

def self.default_store
  @default_store
end

.inspectObject



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

def self.inspect
  (@default_store || self).inspect
end

.load_directory(path) ⇒ Object

Creates a default store and loads a directory into it

Parameters:

  • path (String)

    path to a directory with yml files



16
17
18
19
# File 'lib/konfig.rb', line 16

def self.load_directory(path)
  @default_store ||= Konfig::Store.new
  @default_store.load_directory(path)
end

.pathString

Returns the path where config files are located

Returns:

  • (String)

    returns the path where config files are located



8
9
10
# File 'lib/konfig/rails/railtie.rb', line 8

def self.path
  @path = File.join(Rails.root, "config", "settings")
end