Class: Global::Backend::Filesystem

Inherits:
Object
  • Object
show all
Defined in:
lib/global/backend/filesystem.rb

Overview

Loads Global configuration from the filesystem

Available options:

  • ‘path` (required): the directory with config files

  • ‘environment` (required): the environment to load

  • ‘yaml_whitelist_classes`: the set of classes that are permitted to unmarshal from the configuration files

For Rails:

  • the ‘path` is optional and defaults to `config/global`

  • the ‘environment` is optional and defaults to the current Rails environment

Constant Summary collapse

FILE_ENV_SPLIT =
'.'
YAML_EXT =
'.yml'

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Filesystem

Returns a new instance of Filesystem.



20
21
22
23
24
25
26
27
28
29
# File 'lib/global/backend/filesystem.rb', line 20

def initialize(options = {})
  if defined?(Rails)
    @path = options.fetch(:path) { Rails.root.join('config', 'global').to_s }
    @environment = options.fetch(:environment) { Rails.env.to_s }
  else
    @path = options.fetch(:path)
    @environment = options.fetch(:environment)
  end
  @yaml_whitelist_classes = options.fetch(:yaml_whitelist_classes, [])
end

Instance Method Details

#loadObject



31
32
33
# File 'lib/global/backend/filesystem.rb', line 31

def load
  load_from_path(@path)
end