Class: RecordLoader::Base

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

Overview

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

Constant Summary collapse

BASE_CONFIG_PATH =
%w[config default_records].freeze
EXTENSION =
'.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)

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

  • directory (Pathname, String)

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


22
23
24
25
26
# File 'lib/record_loader/base.rb', line 22

def initialize(files: nil, directory: default_path)
  path = directory.is_a?(Pathname) ? directory : Pathname.new(directory)
  @files = path.children.select { |child| yaml?(child) && in_list?(files, child) }
  load_config
end