Class: ConfigLoader::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/config_loader/base.rb

Overview

Inherit from ConfigLoader base to automatically load one or more yaml files into a @config hash. Config folders are found in config/ and each loader should specify its own subfolder by setting the config_folder class attribute.

Constant Summary collapse

BASE_CONFIG_PATH =
%w[config].freeze
EXTENSION =
'.yml'
WIP_EXTENSION =
'.wip.yml'

Instance Method Summary collapse

Constructor Details

#initialize(files: nil, directory: default_path) ⇒ Base

Create a new config loader from yaml files

Parameters:

  • files (Array, NilClass) (defaults to: nil)

    pass in an array of files to load, or nil to load all files.

  • directory (Pathname, String) (defaults to: default_path)

    The directory from which to load the files. defaults to config/default_records/plate_purposes



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

def initialize(files: nil, directory: default_path)
  path = directory.is_a?(Pathname) ? directory : Pathname.new(directory)

  @files = path.children.select { |child| should_include_file?(files, child) }
  load_config
end