Config::Model::Value::Update(3pm)

NAME
Config::Model::Value::Update - Retrieve data from several external files

VERSION
version 2.166

SYNOPSIS
    # in a model declaration:
    element => [
        data_from_some_file => {
            type => 'leaf',
            value_type => 'uniline',
            update => {
                # handled by this module, Config::Model::Value::Update
                when_missing => 'warn',
                files => [
                    {
                        # handled by Config::Model::Value::UpdateFromFile
                        type => 'ini',
                        file => "some_file.ini",
                        subpath => "foo.bar"
                    },
                    {
                        # ...
                    }
                ]
            }
        },
    ],

DESCRIPTION
This class retrieves data from external files. For each file, caller must specify the file path, the file type (e.g. JSON, Yaml...) and the path inside the file to retrieve data.

Constructor
Constructor parameters are:

files
    Configuration data to build an array of Config::Model::Value::UpdateFromFile objects.

when_missing
    Behavior when no data is found in any file. Can be "ignore", "warn" or "die".

location
    location of the calling value element. This is used to log messages.

methods

  get_info
Return all files and subpaths used to extract data.

  get_update_value
Try to get data from the external files. The files are tried in the same order as the "files" parameter. Data is returned at the first successful try. If no data can be found, either if all files are missing or all subpath do not yield data, this function either returns, warns or die, depending on the value of "when_missing" parameter.

Examples
  update => {
    when_missing => 'ignore',
    files => [
      {
         type => 'yaml',
         file => 'META.yml',
         subpath => 'abstract'
      },
      {
         type => 'json',
         file => 'package.json'
         subpath => 'description'
      }
    ]
  }

SEE ALSO
Config::Model::Value, Config::Model::Value::UpdateFromFile

AUTHOR
Dominique Dumont

COPYRIGHT AND LICENSE
This software is Copyright (c) 2005-2022 by Dominique Dumont.

This is free software, licensed under:

  The GNU Lesser General Public License, Version 2.1, February 1999