Module: YamlConfigurable

Included in:
PgObjects::Config
Defined in:
lib/pg_objects/yaml_configurable.rb

Overview

A module that provides a method to load configuration settings from a YAML file.

Instance Method Summary collapse

Instance Method Details

#load_from_yaml(file_path) ⇒ Object

Loads configuration settings from a YAML file.

Parameters:

  • file_path (String)

    The path to the YAML file.



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

def load_from_yaml(file_path)
  return unless File.exist?(file_path)

  config_hash = YAML.load_file(file_path)

  set_if_present(config, :before_path, config_hash.dig('directories', 'before'))
  set_if_present(config, :after_path, config_hash.dig('directories', 'after'))
  set_if_present(config, :extensions, config_hash['extensions'])
  set_if_present(config, :silent, config_hash['silent'])
end