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.



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

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

  settings_from(YAML.load_file(file_path)).each do |key, value|
    set_if_present(config, key, value)
  end
rescue Psych::SyntaxError => e
  warn "[pg_objects] Ignoring malformed YAML config #{file_path}: #{e.message}"
end