Module: ConfigLoader

Defined in:
lib/config_loader/base.rb,
lib/config_loader/json.rb,
lib/config_loader/yaml.rb,
lib/rails_config_loader.rb,
lib/config_loader/delegator.rb

Defined Under Namespace

Modules: Delegator Classes: Base, Json, Yaml

Instance Method Summary collapse

Instance Method Details

#load(file_path, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/rails_config_loader.rb', line 6

def load file_path, options = {}
	ext 	 = File.basename(file_path).split(/(ya?ml|json)$/).last
	loader = case ext.to_sym
	when :json
		ConfigLoader::Json
	when :yml, :yaml
		ConfigLoader::Yaml
	end
	loader.new file_path, options = {}
end

#load_hash(file_path, options = {}) ⇒ Object



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

def load_hash file_path, options = {}
	load(file_path, options).as_hash
end

#load_json(file_path, options = {}) ⇒ Object



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

def load_json file_path, options = {}
	ConfigLoader::Json.new file_path, options = {}
end

#load_yaml(file_path, options = {}) ⇒ Object



21
22
23
# File 'lib/rails_config_loader.rb', line 21

def load_yaml file_path, options = {}
	ConfigLoader::Yaml.new file_path, options = {}
end