Class: ConfigPlus::DefaultLoaderLogic

Inherits:
Object
  • Object
show all
Defined in:
lib/config_plus/default_loader_logic.rb

Overview

This loader reads configuration from the specified a YAML file with its load_from method. When a directory is specified this recurses a file tree and reads all YAML files.

Direct Known Subclasses

ErbYamlLoaderLogic

Instance Method Summary collapse

Constructor Details

#initialize(extension) ⇒ DefaultLoaderLogic

Returns a new instance of DefaultLoaderLogic.



10
11
12
# File 'lib/config_plus/default_loader_logic.rb', line 10

def initialize(extension)
  @extension = extension || [:yml, :yaml]
end

Instance Method Details

#load_from(path) ⇒ Object

Raises:

  • (Errno::ENOENT)


14
15
16
17
18
# File 'lib/config_plus/default_loader_logic.rb', line 14

def load_from(path)
  raise Errno::ENOENT, "No such file or directory: `#{path}'" unless File.exist?(path)
  return load_file(path) if File.file?(path)
  load_dir(path)
end